faqts : Computers : Programming : Languages : Python : Common Problems : IDLE

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 21 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

Using non-ASCII characters like German umlauts gives errors in IDLE. Is there a solution?

Sep 23rd, 2001 15:54
Gerhard Haering,


You have to set Python's default encoding to the character set you 
use. For countries in Central Europe, this would be "iso-8859-1", for 
Eastern Europe, Russia, Asia, etc. that's a different character set.
You can change Python's default encoding by putting a file 
"sitecustomize.py" somewhere in Python's search path.
A possible place on Unix is the site-packages directory of your Python 
installation.
A possible place on Windows is the directory python.exe is in 
(c:\Python21 by default).
Put the following two lines in the sitecustomize.py file:
import sys
sys.setdefaultencoding("iso-8859-1")
and change the default encoding ("iso-8859-1") to yours.