0

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 !

suizokukan
  • 1,303
  • 4
  • 18
  • 33
  • possible duplicate of [ConfigParser with Unicode items](http://stackoverflow.com/questions/1648517/configparser-with-unicode-items) – Piotr Dobrogost Jul 23 '13 at 19:55

1 Answers1

2

In ConfigParser with Unicode items they offer:

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

Have you tried that? Cheers!

Community
  • 1
  • 1
Jblasco
  • 3,827
  • 22
  • 25