[Tutor] Declaring encoding question
ml.cyresse at gmail.com
Sat Aug 20 03:26:47 CEST 2005
I've got some source code which will be handling non-ASCII chars like
umlauts and what not, and I've got a testing portion stored in the
I get this deprecation warning when I run my code -
__main__:1: DeprecationWarning: Non-ASCII character '\xfc' in file
C:\Python24\testit.py on line 733, but no encoding declared; see
http://www.python.org/peps/pep-0263.html for details
I'm reading this - http://www.python.org/peps/pep-0263.html
Now, the non-ASCII character is in the test data, so it's not actually
part of my code.
Will Python be able to handle \xfc and company in data without my
telling it to use a different form of encoding?
When I run the code, and get my returned data, it looks like this in
>>> print j["landunits"].keys()
['"J\xe4ger"', '"Deutschmeister"', '"Army of Bohemia"',
'"Gardegrenadiere"', '"K.u.K Armee"', '"Erzherzog"', '"Army of
Italy"', '"Army of Silesia"', '"Army of Hungary"']
So J\xe4ger is actually Jäger. When I run it slightly differently -
>>> for item in j["landunits"].keys():
... print item
"Army of Bohemia"
"Army of Italy"
"Army of Silesia"
"Army of Hungary"
It prints the umlauted 'a' fine and dandy.
So, do I have to do anything to ensure that Python will continue to
display the non-ASCII chars? I intend to have my output delivered via
a Pythoncard/wxPython GUI, and I'm not sure if it's the Python
interpreter displaying it properly, or Pythonwin making a special
More information about the Tutor