[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: UTF8 to/from Unicode?
- From: Xavier Wang <weasley.wx@...>
- Date: Sun, 1 Feb 2015 06:15:28 +0800
2015-01-31 19:37 GMT+08:00 Dirk Laurie <dirk.laurie@gmail.com>:
> 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))
--
regards,
Xavier Wang.