-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
Description
I am not sure if this is a bug or just my not understanding. This is under Python 2.7, using v5.0.4 from pip. I can't seem to write out a CfgObj that has unicode strings. Here's a simple scenario:
File: 'in.ini'
folder="Arbeitsfläche"
code:
from configobj import ConfigObj
cfg = ConfigObj("in.ini", encoding="UTF8")
print u"folder string[{0}] and repr [{1}]".format(cfg['folder'], repr(cfg['folder']))
cfg.filename = "out.ini"
cfg.write()produces this:
folder string[Arbeitsfläche] and repr [u'Arbeitsfl\xe4che']
Traceback (most recent call last):
File "stackoverflow.py", line 7, in <module>
cfg.write()
File "/usr/local/lib/python2.7/site-packages/configobj.py", line 2124, in write
'ascii'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 18: ordinal not in range(128)
There doesn't seem to be any problem reading the file in. Also, if I change the input file to have the value "Desktop" instead of "Arbeitsfläche", no problem.
What I can't understand is why it wants to use the ascii codec, when I've explicitly set the UTF8 encoder.
Any help would be appreciated!
Reactions are currently unavailable