unable to print Unicode characters in Python 3

John Machin sjmachin at lexicon.net
Tue Jan 27 19:41:16 EST 2009


On Jan 27, 6:17 pm, "Martin v. Löwis" <mar... at v.loewis.de> wrote:
> > Well, the first step would be to tell Python that there is a code page
> > 65001. On Python 2.6, I get a LookupError for an unknown encoding after
> > doing "chcp 65001". I checked the list of aliases in Python 3 and there
> > was no entry for cp65001.
>
> I see. What happens if you add it to encoding/aliases.py?

A slight improvement. Get this:

C:\junk\console>chcp 65001
Active code page: 65001

C:\junk\console>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.stdout.encoding
'cp65001'
>>> print u'\xff'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
LookupError: unknown encoding: cp65001
>>> print u'\xff'.encode('utf8')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied
>>>

Adding an entry to ...\lib\encodings\aliases.py as suggested did fix
the Lookup error; it took it straight to the same IOError as above.

Next step?



More information about the Python-list mailing list