UnicodeError...
Martin v. Loewis
martin at v.loewis.de
Mon Jul 29 19:20:05 EDT 2002
Teemu Luojola <tempe at pp.inet.fi> writes:
> This
> problem is dealt in Python FAQ in chapter 4.102. and the following
> solution is given:
>
> > # Set the string encoding used by the Unicode implementation.
> > # The default is 'ascii'
> > encoding = "ascii" # <= CHANGE THIS if you wish
[...]
> The problem is, that sys doesn't include setdefaultencoding().
I don't believe you. Did you try to modify this very location in
site.py? At that point, sys.setdefaultencoding is still present.
> Tell me, please, how to get that Unicode build.
I'm pretty sure you have a Unicode build.
> When running Python in command line mode, there is no UnicodeError and
> print 'åäö' returns the expected result: 'åäö'. Why there is such a
> difference?
IDLE is written with Tkinter, which returns Unicode strings to the
interpreter; the interpreter then needs to convert them into source
code (which means byte strings). The command line interpreter reads
from the console window, and already gets byte strings - hence no need
to convert them.
Regards,
Martin
More information about the Python-list
mailing list