Frage

My Python3 project works well on Linux but I got a problem with the configparser module on Windows. Every files of my own are encoded using UTF-8/unicode.

The following code :

    CONFIG_INI = configparser.ConfigParser()
    CONFIG_INI.read( "config.ini" )

raises an error when launched from cmd.exe :

    [..., from c:\Python33\lib\encodings\cp1252.py]
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x90 [...]

So, why does my program use the CP1252 encoding instead of the unicode one ? I can't see on the configparser page how to set a specific encoding.

Any idea ? Thank you !

War es hilfreich?

Lösung

In ConfigParser with Unicode items they offer:

cfg.readfp(codecs.open("myconfig", "r", "utf8"))

Have you tried that? Cheers!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top