lua-users home
lua-l archive

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


JM Fernandez wrote:
I have a file encoded in iso-8859-1 but I want to show it at the screeen
in the charset used by the os (after convert it in some way), let say utf-8.

Is there some way to detect from Lua the charset used by the OS to
proceed adequately? (probably in Linux, Windows and Mac the way,
if exists, is different).

Apart from this, is there a simple way to convert from iso-8859-1 to utf-8
(without iconv), a sort of inverse function of toISO in

    http://lua-users.org/lists/lua-l/2003-10/msg00281.html

AFAIK, iso-8859-1 codes 0xA0 to 0xFF corresponds to the same codepoints in Unicode, so you just need a straight conversion to 2-byte utf-8, where:

   0000 0080-0000 07FF | 110xxxxx 10xxxxxx

Some arithmetic and a couple of char conversions is not terribly fast in Lua if you're processing gigabytes, but tens of KBs ought to be no problem...

--
Cheers,
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia