unable to print Unicode characters in Python 3

Benjamin Kaplan benjamin.kaplan at case.edu
Wed Jan 28 02:11:35 CET 2009


On Tue, Jan 27, 2009 at 7:41 PM, John Machin <sjmachin at lexicon.net> wrote:

> 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?


Wait for Microsoft to catch up to everyone else? I tried this on Windows 7
beta. I didn't get an IOError, but the command prompt apparently doesn't
understand the concept of a multi-byte character. u'\xff' showed as 2
unprintable characters. At least it's an improvement.

>
>  --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090127/8a5b3284/attachment.html>


More information about the Python-list mailing list