lua-users home
lua-l archive

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


On Thu, Feb 9, 2012 at 6:37 PM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> utf8.char(cp1, cp2, ...) -> string formed by code points cp1, cp2, ...
> (If cp1 is a table, string formed by the code points in it?)

How about if cp1 is a function, it builds the string from (the equivalent of):

 for _, codepoint in cp1, cp2, ... do
   -- append codepoint
 end

Then if you have an ichars() method that returns a codepoint iterator,
and you have the same API for other encodings, converting from one
encoding to another becomes pretty easy:

 u8encoded = utf8.char(utf16.ichars(u16encoded))

-Duncan