lua-users home
lua-l archive

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


Hello

'less' is not a possibility (?) because some strings
are internal ones.

The specific problem is the following.
I have some strings in UTF-8, others in iso-8859
(obviously I know the charset of the strings).
Then I want to show them in a terminal. I need the
os charset because the strings have to be
converted into it to displaying purposes.
And obviously I want my program working
in several platforms with little trouble.

The problem perhaps is the not standardization of many
os (I have not used windows vista nor windows 7 nor mac)
in this regard.

I tried

os.setlocale(nil, "ctype")

In my old debian it returns

es_ES@euro  (I am from Spain)

in windows xp it returns

C

No indication about charset (is it in this case iso-8859
or ansi---equivalent?)

However in a new ubuntu the response is

es_ES.UTF-8

Therefore, can I admit that when no UTF-8 or UTF8 (with lowercase
varitions) appears then iso-8859 is a good assumption?

I believe that in the future all usual os will be standard (some kind
of UTF) in this and the present problem is gone.

Manel


2010/2/27, Sam Roberts <vieuxtech@gmail.com>:
> On Sat, Feb 27, 2010 at 8:03 AM, JM Fernandez <elcubion@gmail.com> 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).
>
> Linux and Mac both have unix terminals, who knows about Windows.
>
> Why not pass it to a pager and let it deal with this for you, like
> /usr/bin/less?
>
> os.execute("LESSCHARSET=latin1 /usr/bin/less -F -E"..your_file)
>
> Then only windows would have to special, unless you have less there,
> you might have
> to use more.
>
> Sam
>