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
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

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:  2925 Time(s)

UTF-8 Displayed with lua.JPG



Displaying UTF8.lua
 Description:

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


_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 148

Joined: 07 Nov 2008
Posts: 4184
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
Master Cheater
Reputation: 8

Joined: 10 Apr 2015
Posts: 425

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:  2817 Time(s)

Capture1.JPG



_________________
I can't do it now because I don't know yet and because You knew it before me. There is heaven above the sky.
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