[Pythonmac-SIG] How to print unicode to OS-X Terminal.app
ronaldoussoren at mac.com
Fri Feb 15 13:42:47 CET 2008
On 15 Feb, 2008, at 0:11, Christopher Barker wrote:
> Robin Dunn wrote:
>> Just replace sys.stdout with an object with a write() method that
>> what you want.
> I don't think that will do it, as "print" will have already converted
> the object to a string, and it does that with str(), which calls
> object.__str__, which used the default encoding....
> oh well, I'm really just whining, but this transition to unicode is
> pretty painful!
On my system print u"text" already does the right thing, even when the
text contain non-ascii characters. This is with the system install of
>>> import sys
That's because the system (OSX 10.5) has set an environment variable
that Python knows about: LANG=en_US.UTF-8.
> Christopher Barker, Ph.D.
> Emergency Response Division
> NOAA/NOS/OR&R (206) 526-6959 voice
> 7600 Sand Point Way NE (206) 526-6329 fax
> Seattle, WA 98115 (206) 526-6317 main reception
> Chris.Barker at noaa.gov
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
More information about the Pythonmac-SIG