lua-users home
lua-l archive

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

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 ... )



[3]	I haven't even moved to Lua 5.2 yet.