Author vstinner
Recipients grego87, nirai, vstinner
Date 2010-01-07.01:30:04
SpamBayes Score 8.44608e-05
Marked as misclassified No
Message-id <1262827807.0.0.685299656327.issue7519@psf.upfronthosting.co.za>
In-reply-to
Content
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)
-------------------------------------
History
Date User Action Args
2010-01-07 01:30:07vstinnersetrecipients: + vstinner, nirai, grego87
2010-01-07 01:30:07vstinnersetmessageid: <1262827807.0.0.685299656327.issue7519@psf.upfronthosting.co.za>
2010-01-07 01:30:05vstinnerlinkissue7519 messages
2010-01-07 01:30:04vstinnercreate