[Python-Dev] Proposal: new environment variable PYTHONSTDOUTENCODING (original) (raw)

M.-A. Lemburg mal at egenix.com
Tue May 20 20:56:26 CEST 2008


On 2008-05-20 20:23, Martin v. Löwis wrote:

Writing Unicode to stdout will still use the default encoding ASCII to convert it to an 8-bit string. That's not true.

Are you sure ?

setenv LC_ALL de_DE.utf8 python2.5 Python 2.5 (r25:51908, May 9 2007, 00:53:06)

u = u'äöü' sys.stdout.write(u) Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) print u äöü

Only "print" will set the Py_PRINT_RAW flag to trigger the conversion from Unicode to 8-bit strings using .encoding in PyFile_WriteObject().

If not set, the default encoding is used.

I'm not exactly sure why, since using .encoding would be useful in all cases.

-- Marc-Andre Lemburg eGenix.com

Professional Python Services directly from the Source (#1, May 20 2008)

Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/


:::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
        Registered at Amtsgericht Duesseldorf: HRB 46611


More information about the Python-Dev mailing list