lua-users home
lua-l archive

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

2015-01-31 19:37 GMT+08:00 Dirk Laurie <>:
> I wish to make use of a library that expects its strings to be in
> 32-bit Unicode.
> What is the recommended way in Lua 5.3 of converting to/from UTF8?

maybe you can work together with utf8.len, utf8.codepoint and
string.pack, like this (untested):

local result = string.pack(("I4"):rep(utf8.len(s)), utf8.codepoint(s))

Xavier Wang.