Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Unicode / UTF-8 string pattern

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Thu Mar 30, 2017 4:26 am    Post subject: Unicode / UTF-8 string pattern Reply with quote

Hi there, I tried a test a lua function to handle Unicode / UTF-8 character using lua, so it can use to write or display unicode on a label, listbox, form, etc.

Lua file as attached (copy paste to CE table lua script and execute).

Example :

Code:
t1 = {}
s1 = "こんにちは世界=Japan"
for k, v in utf8.gmatch(s1, "([^%p%s%c]+)=([^%p%s%c]+)") do
    t1[k] = v
end
for k,v in pairs(t1) do
lb2cap = print(k,v)
end
lb2.Caption = lb2cap

-- lb2.Caption will show as "こんにちは世界 Japan"


But i have problem for Russian character :

Code:
s = "Привет, мир, от Russia"
for w in utf8.gmatch(s, "[^%p%d%s%c]+") do
    print(w)
end
[[ it show as :
Привет
мир
от
Lua
]]

[[ i want it show as :  "Привет, мир, от Russia"]]


which string pattern can use for that ?

Thanks



UTF-8 Displayed with lua.JPG
 Description:
 Filesize:  22.44 KB
 Viewed:  8349 Time(s)

UTF-8 Displayed with lua.JPG



Displaying UTF8.lua
 Description:

Download
 Filename:  Displaying UTF8.lua
 Filesize:  23.77 KB
 Downloaded:  533 Time(s)


_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Mar 31, 2017 3:25 am    Post subject: Reply with quote

Code:
s = "Привет, мир, от Russia"
for w in s:gmatch("[^%p%d%s%c]+") do
    print(w)
end


shows:
Привет
мир
от
Russia



About displaying:

_________________
Back to top
View user's profile Send private message MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Fri Mar 31, 2017 6:41 am    Post subject: Reply with quote

Ah..I see, mgr.inz.Player.

So, no need a function to handle UTF-8/Unicode since CE 6.5 / CE 6.6 (lua 5.3), right ? or is it depending by system operation installed on computer ?. Need to know if this correct displaying on other computer / system.

I tried this because someone post that he can't displaying Chinese or Japanese character on a list box, but the OP already delete within a minute after he/she posted it (seem delete post often happens lately Wink )

btw, work on my machine (tested) :

Code:
f = createForm()

lb = createListBox(f)
lb.Top = f.Top + 10
lb.Height = f.Height - lb.Top - 10
lb.Left = 10
lb.Width = f.Width - lb.Left - 10
lb.Items.Add('こんにちは, Japan')
lb.Items.Add('Բարեւ, Armenian')
lb.Items.Add('مرحبا, Arabic')
lb.Items.Add('你好, China')
lb.Items.Add('Здравствуйте, Russia')
lb.Items.Add('Χαίρετε, Greek')

f.show()


Thanks



Capture1.JPG
 Description:
 Filesize:  22.02 KB
 Viewed:  8241 Time(s)

Capture1.JPG



_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites