lua-users home
lua-l archive

Re: from ascii to hex for unicode char

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Try this:
print(string.format("0x%x", utf8.byte("ည",1,-1)))
string.format accepts the same format codes as C printf, and %x prints an integer as a hex value.
Hope that helps,
Chris Swetenham
----- Original Message ----- From: "Jelle Huisman" <jelle@jhnet.nl>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Friday, February 15, 2008 3:38 PM
Subject: from ascii to hex for unicode char
Hello,
I try to analyse a unicode character, e.g. "ည". I am able to get the
ascii code for this string using: print(utf8.byte("ည",1,-1))
This gives me 4106, which is correct. However I would like to get the
unicode codepoint in hex notation, for this character this would be:
0x100A How do I get this result? (I use the slnunicode library)
Thanks,
Jelle

AltStyle によって変換されたページ (->オリジナル) /