This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Redoute
Recipients Redoute
Date 2012-03-04.09:42:29
SpamBayes Score 3.316362e-08
Marked as misclassified No
Message-id <1330854154.2.0.961318278787.issue14192@psf.upfronthosting.co.za>
In-reply-to
Content
When running a python script from windows command line (cmd.exe) and redirecting its output, stdout.encoding is set to None and printing non-ascii chars fails. Encoding should be the same as without redirecting.
Example:

[Code unictest.py]
# -*- coding: utf-8 -*-

from sys import stdout, stderr
print >> stderr, 'stdout.encoding: ', stdout.encoding
print u'äöüß'
[/Code]

[windows command prompt]
C:\Daten>testunic.py
stdout.encoding:  cp850
äöüß

C:\Daten>testunic.py > testunic.txt
stdout.encoding:  None
Traceback (most recent call last):
  File "C:\Daten\Cmd\testunic.py", line 5, in <module>
    print u'├ñ├Â├╝├ƒ'
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordin
al not in range(128)
[/windows command prompt]
History
Date User Action Args
2012-03-04 09:42:34Redoutesetrecipients: + Redoute
2012-03-04 09:42:34Redoutesetmessageid: <1330854154.2.0.961318278787.issue14192@psf.upfronthosting.co.za>
2012-03-04 09:42:29Redoutelinkissue14192 messages
2012-03-04 09:42:29Redoutecreate