Displaying ipa in python.exe

Ben Last ben at benlast.com
Thu Aug 19 03:00:00 EDT 2004


From: Burgel Rosa Maria Faehndrich
>I am having some trouble properly displaying unicode characters in
python.exe.
>print ur"\u0288"
>print ur"\u0288".encode('utf-8')
You don't say what environment (operating system, window type, etc) you're
running Python.exe under, though from the fact you say "python.exe" rather
than "python" I'd guess Windows.  Different versions of Windows have
different levels of support for Unicode, but if IDLE displays what you want,
I suspect you're on 2000/XP, which makes this more of a Windows question
than a Python one, but here we go anyway...

The Windows "console" (Start/Run.../cmd.exe) supports one "code page" at a
time.  Each code page interprets the 256 8-bit characters as a different set
of symbols.  None of them will support all Unicode characters.  You can
change the code page that a given console window is using via the CHCP
command.  CMD supports a "/U" switch, but that just controls the type of
output to a file or pipe (/U makes it unicode, /A makes it ANSI).

So, the short answer is that you cannot display arbitrary Unicode strings
via the console.  You can work out what code page the console is using, and
try and encode Unicode to strings in that encoding (myString.encode("cp850")
on my system here), but it may well not be able to show it.

regards
ben




More information about the Python-list mailing list