Need debugging knowhow for my creeping Unicodephobia

John Nagle nagle at animats.com
Sat Feb 13 00:48:30 EST 2010


kj wrote:
> Some people have mathphobia.  I'm developing a wicked case of
> Unicodephobia.
> 
> I have read a *ton* of stuff on Unicode.  It doesn't even seem all
> that hard.  Or so I think.  Then I start writing code, and WHAM:
> 
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 0: ordinal not in range(128)

    First, you haven't told us what platform you're on.  Windows?  Linux? 
Something else?

    If you're on Windows, and running Python from the command line, try
"cmd /u" before running Python. This will get you a Windows console that
will print Unicode.  Python recognizes this, and "print" calls will
go out to the console in Unicode, which will then print the correct
characters if they're in the font being used by the Windows console.
Most European languages are covered in the standard font.

    If you're using IDLE, or some Python debugger, it may need to be
told to have its window use Unicode.

					John Nagle



More information about the Python-list mailing list