On 10 jan, 11:53, 88888 Dihedral <dihedral88...@googlemail.com> wrote: > Terry Reedy於 2012年1月10日星期二UTC+8下午4時08分40秒寫道: > > > > I get the same error running 3.2.2 under IDLE but not when pasting into > > Command Prompt. However, Command Prompt may be cheating by replacing the > > Chinese chars with '??' upon pasting, so that Python never gets them -- > > whereas they appear just fine in IDLE. > > > --
Tested with *my* Windows GUI interactive intepreters. It seems to me there is a problem with the mbcs codec. >>> hex(ord('工')) '0x5de5' >>> '\u5de5' '工' >>> '\u5de5'.encode('mbcs') Traceback (most recent call last): File "<eta last command>", line 1, in <module> UnicodeEncodeError: 'mbcs' codec can't encode characters in position 0--1: invalid character >>> '\u5de5'.encode('utf-8') b'\xe5\xb7\xa5' >>> '\u5de5'.encode('utf-32-be') b'\x00\x00]\xe5' >>> sys.version '3.2.2 (default, Sep 4 2011, 09:51:08) [MSC v.1500 32 bit (Intel)]' >>> '\u5de5'.encode('mbcs', 'replace') b'?' ---------- >>> u'\u5de5'.encode('mbcs', 'replace') '?' >>> repr(u'\u5de5'.encode('utf-8')) "'\\xe5\\xb7\\xa5'" >>> repr(u'\u5de5'.encode('utf-32-be')) "'\\x00\\x00]\\xe5'" >>> sys.version '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]' jmf -- http://mail.python.org/mailman/listinfo/python-list