Message97335
Use utf_8_sig charset and open your file using io.open() or codecs.open() to get unicode sections, options and values.
Example:
-------------------------------------
from ConfigParser import ConfigParser
import io
# create an utf-8 .ini file with a BOM marker
with open('bla.ini', 'wb') as fp:
fp.write(u'[section]\ncl\xe9=value'.encode('utf_8_sig'))
# read the .ini file
config = ConfigParser()
with io.open('bla.ini', 'r', encoding='utf_8_sig') as fp:
config.readfp(fp)
# dump the config
for section in config.sections():
print "[", repr(section), "]"
for option in config.options(section):
value = config.get(section, option)
print "%r=%r" % (option, value)
------------------------------------- |
|
Date |
User |
Action |
Args |
2010-01-07 01:30:07 | vstinner | set | recipients:
+ vstinner, nirai, grego87 |
2010-01-07 01:30:07 | vstinner | set | messageid: <1262827807.0.0.685299656327.issue7519@psf.upfronthosting.co.za> |
2010-01-07 01:30:05 | vstinner | link | issue7519 messages |
2010-01-07 01:30:04 | vstinner | create | |
|