unicode to hexadecimal

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

unicode to hexadecimal

Post by terryho » Fri May 03, 2019 10:12 am

Hi All

I want to convert unicode Chinese character to hex value. I can use the following to convert english to hex value.

put charToNum("P") into tNum
answer baseConvert(tNum,10,16) ; return 70

If I use a Chinese character "中" in the above it will return "3F". which is not correct. The correct value is "\u4E2D".

Please advise how can I make it!

Regards

Terry Ho

Klaus
Posts: 13853
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: unicode to hexadecimal

Post by Klaus » Fri May 03, 2019 10:25 am

Ni hao Terry,

just guessing, but maybe using something like codepointtonum() etc. will do the job?
CHARTONUM() has been deprecated with the introduction of Unicode.


Best

Klaus

terryho
Posts: 126
Joined: Mon Nov 05, 2012 2:53 pm

Re: unicode to hexadecimal

Post by terryho » Sat May 04, 2019 5:50 am

Hi Klaus,

Thanks your help. It is working.

Regards

Terry Ho

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”