Re: Python strings outside the 128 range
>>>>Michael Piotrowski <mxp@dynalabs.d e(MP) wrote:
But if LANG isn't set (like on Mac OS X) this doesn't give you the proper
encoding.
On my system I have added LANG to .profile.
--
Piet van Oostrum <piet@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C 4]
Private email: piet@vanoostrum .org
>>>>Michael Piotrowski <mxp@dynalabs.d e(MP) wrote:
>MPOn 2006-07-14 "Diez B. Roggisch" <deets@nospam.w eb.dewrote:
>>Sybren Stuvel schrieb:
>>>Diez B. Roggisch enlightened us with:
>>>>Of course not. AFAIK there is no way figuring out which encoding the
>>>>target console supports. The best you can do is to offer an option
>>>>that allwos selection of the output encoding.
>>>>
>>>You can use the LANG environment variable on many systems. On mine,
>>>it's set to en_GB.UTF-8, which causes a lot of software to
>>>automaticall y choose the right encoding.
>>>
>>That might be a good heuristic - but on my Mac no LANG is set. So I
>>should paraphrase my statement to "There is no reliable and
>>cross-platform way figuring out which encoding the console uses".
>>>Diez B. Roggisch enlightened us with:
>>>>Of course not. AFAIK there is no way figuring out which encoding the
>>>>target console supports. The best you can do is to offer an option
>>>>that allwos selection of the output encoding.
>>>>
>>>You can use the LANG environment variable on many systems. On mine,
>>>it's set to en_GB.UTF-8, which causes a lot of software to
>>>automaticall y choose the right encoding.
>>>
>>That might be a good heuristic - but on my Mac no LANG is set. So I
>>should paraphrase my statement to "There is no reliable and
>>cross-platform way figuring out which encoding the console uses".
>MPIf LANG is not set, it's equivalent to setting it to "C". However,
>MPyou shouldn't look directly at these variables (LANG and LC_*) but
>MPrather use the functions from the locale module, e.g.:
>MPyou shouldn't look directly at these variables (LANG and LC_*) but
>MPrather use the functions from the locale module, e.g.:
>MP import locale
>MP locale.setlocal e(locale.LC_ALL , '') # use the current locale settings
>MP encoding = locale.nl_langi nfo(locale.CODE SET)
>MP locale.setlocal e(locale.LC_ALL , '') # use the current locale settings
>MP encoding = locale.nl_langi nfo(locale.CODE SET)
encoding.
On my system I have added LANG to .profile.
--
Piet van Oostrum <piet@cs.uu.n l>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C 4]
Private email: piet@vanoostrum .org
Comment