Is it possible to detect if a Lua string contains non-ascii characters?
I am reading userdata from Facebook and need to detect if the user’s name contains other language characters… [import]uid: 64174 topic_id: 34721 reply_id: 334721[/import]
Is it possible to detect if a Lua string contains non-ascii characters?
I am reading userdata from Facebook and need to detect if the user’s name contains other language characters… [import]uid: 64174 topic_id: 34721 reply_id: 334721[/import]
UP
want to know if to do this…
built-in support? no. lua strings are essentially “dumb 8-bit blobs” and can store anything - including binary data with embedded zeros (unlike C strings, for instance), and the string functions have no knowledge of multi-byte characters.
you’d need to know the encoding scheme, then you could “reverse engineer” it to get your count. if it’s UTF-8 for example, then there are reserved octets for marking multi-byte chars that you could count (by iterating char by char, or gsub’ing them, or etc…)
searching for “lua unicode” might turn up something? idk
hth
UP
want to know if to do this…
built-in support? no. lua strings are essentially “dumb 8-bit blobs” and can store anything - including binary data with embedded zeros (unlike C strings, for instance), and the string functions have no knowledge of multi-byte characters.
you’d need to know the encoding scheme, then you could “reverse engineer” it to get your count. if it’s UTF-8 for example, then there are reserved octets for marking multi-byte chars that you could count (by iterating char by char, or gsub’ing them, or etc…)
searching for “lua unicode” might turn up something? idk
hth