ConfigParser and Unicode

thehaas at thehaas at
Thu Mar 18 18:41:36 CET 2004

I'm trying to read a config file with Unicode characters via
ConfigParser with Python 2.3 and am having some problems.  The file
looks like:


This is how I'm trying to read it:
  config = ConfigParser()"work.cfg")
  goodProcRef = config.get(section,"goodprocref").split(",")

goodProcRef now looks like this:
   >>> goodProcRef
   ['PYTHON', 'RSS', 'Gr\xfc\xdf', 'LDAP'] 

Obviously, 'Grüß'!='Gr\xfc\xdf' .  If I change the split to use u","
instead, I get the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "", line 165, in parseConfig
    goodProcRef = config.get(section,"goodprocref").split(u",")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xfc in position 13: ordinal not in range(128)

Any ideas on how I can get the correct value?

Mike Hostetler          
thehaas at 

More information about the Python-list mailing list