[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: detect the charset used by the os
- From: KHMan <keinhong@...>
- Date: Sun, 28 Feb 2010 00:32:32 +0800
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
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...
Kein-Hong Man (esq.)
Kuala Lumpur, Malaysia