"~flow" <wolfgang.l...@gmail.com> wrote in message news:643ca91c-b81c-483c-a8af-65c93b593...@r33g2000vbp.googlegroups.com...
On Sep 16, 7:16 am, "Mark Tolonen" <metolone+gm...@gmail.com> wrote:
Setting PYTHONIOENCODING overrides the encoding used for stdin/stdout/stderr (See the Python help for details), but if your terminal doesn't support the
encoding that won't help.
[snip]
what has changed in python is that they now somehow find out about the
terminal's encoding, and then put that encoding into place and defend
it with teeth and claws. it is simply not easy to take control of that
setting.

A couple more tips, PYTHONIOENCODING takes an optional errorhandler:

C:\>set PYTHONIOENCODING=cp437:xmlcharrefreplace
C:\>python
Python 3.1.1 (r311:74483, Aug 17 2009, 17:02:12) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
print('Hello \u5000\u5001')
Hello &#20480;&#20481;

You can also write directly to stdout with byte strings (Note: my terminal doesn't support UTF-8, but no error):

import sys
sys.stdout.buffer.write('\u5000'.encode('utf8'))
sÇÇ3

-Mark


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to