Re: locale support and 4.10

2005-03-06 Thread Michael Piotrowski
Timothy Smith <[EMAIL PROTECTED]> writes:

> something strange is happening, no matter what i try nothing is a 
> supported locale
> and yes it's freebsd 4.10

AFAIK, the locale support in FreeBSD 4.1 is incomplete.  Support for
LC_NUMERIC was only added in 4.6 - the release notes for 4.6 say:

  The locale support was synchronized with the code from FreeBSD
  -CURRENT. This change brings support for the LC_NUMERIC,
  LC_MONETARY, and LC_MESSAGES categories, as well as improvements to
  strftime(3), revised locale definitions, and improvement of the
  localization of many base system programs.

HTH

-- 
Michael Piotrowski, M.A.   <[EMAIL PROTECTED]>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-14 "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:

> 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
>> automatically 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".

If LANG is not set, it's equivalent to setting it to "C".  However,
you shouldn't look directly at these variables (LANG and LC_*) but
rather use the functions from the locale module, e.g.:

  import locale
  locale.setlocale(locale.LC_ALL, '') # use the current locale settings
  encoding = locale.nl_langinfo(locale.CODESET)

-- 
Michael Piotrowski, M.A.   <[EMAIL PROTECTED]>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt>
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python strings outside the 128 range

2006-07-17 Thread Michael Piotrowski
On 2006-07-17 Piet van Oostrum <[EMAIL PROTECTED]> wrote:

>>>> 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".
>
>>> If LANG is not set, it's equivalent to setting it to "C".  However,
>>> you shouldn't look directly at these variables (LANG and LC_*) but
>>> rather use the functions from the locale module, e.g.:
>
>>>   import locale
>>>   locale.setlocale(locale.LC_ALL, '') # use the current locale settings
>>>   encoding = locale.nl_langinfo(locale.CODESET)
>
> But if LANG isn't set (like on Mac OS X) this doesn't give you the proper
> encoding.

Well, yes, but it gives you something "safe" and you can advise the
user to set the locale.

> On my system I have added LANG to .profile.

That's certainly the right thing to do.

-- 
Michael Piotrowski, M.A.   <[EMAIL PROTECTED]>
Public key at <http://www.dynalabs.de/mxp/pubkey.txt>
-- 
http://mail.python.org/mailman/listinfo/python-list