[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: UTF8 to/from Unicode?
- From: Sean Conner <sean@...>
- Date: Sat, 31 Jan 2015 16:18:15 -0500
It was thus said that the Great Dirk Laurie once stated:
> 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?
I have a Lua module [1] for iconv [2], which is what I use when I need to
convert character sets. It's written for Lua 5.1 [3] but it should be
fairly easy to adapt it to Lua 5.3. It's also pretty easy to use:
iconv = require "org.conman.iconv"
tounicode = iconv("UCS-4","UTF-8")
fromunicode = iconv("UTF-8","UCS-4")
x = tounicode("this is a test message")
y = process_unicode_string(x)
z = fromunicode(y)
-spc (I should get my modules to work under Lua 5.3 and make rockspecs for
them ... )
[1] https://github.com/spc476/lua-conmanorg/blob/master/src/iconv.c
[2] http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.13/iconv.1.html
[3] I haven't even moved to Lua 5.2 yet.