[Python-3000] Does Py3k's print offer any unicode encoding help?
Guido van Rossum
guido at python.org
Thu Feb 14 23:38:44 CET 2008
In Leopard (OSX 10.5), it looks like LANG is set to convey this: it
has the value en_US.UTF-8 for me, and I haven't done anything to
change it. The Preferences dialog is completely changed from 10.4 and
there's a checkbox (on by default AFAIK) to set the LANG variable.
(However I've noticed that it doesn't set an encoding when I specify
another encoding other than UTF-8 -- perhaps because there is
interaction with the Language choice.)
In 10.4 LANG isn't set at all. The effect is that in 10.5,
sys.stdout.encoding defaults to UTF-8 but in 10.4 to US-ASCII.
Maybe a decent rule of thumb would be:
- if LANG is set, use the encoding it specifies; if there's no
encoding in it, assume it's ASCII.
- if LANG is *not* set, default to UTF-8 instead of to US-ASCII; UTF-8
is much more likely to be correct and useful for 10.4 and before.
--Guido
On Thu, Feb 14, 2008 at 2:21 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > The code that guesses the default stdout encoding isn't very good,
> > especially not on OSX. Suggestions are welcome.
>
> Unfortunately, Apple isn't very cooperative here. There is no way
> of determining the encoding of a Terminal.app window, AFAIK
> (it's normally UTF-8, unless the user has changed it).
>
> Regards,
> Martin
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list