[Tutor] Encode problem

spir denis.spir at free.fr
Fri May 1 22:06:01 CEST 2009


Le Fri, 1 May 2009 15:19:29 -0300,
"Pablo P. F. de Faria" <pablofaria at gmail.com> s'exprima ainsi:

> self.cfg.write(codecs.open(self.properties_file,'w','utf-8'))
> 
> As one can see, the character encoding is explicitly UTF-8. But
> ConfigParser keeps trying to save it as a 'ascii' file and gives me
> error for directory-names containing >128 code characters (like "Á").
> It is just a horrible thing to me, for my app will be used mostly by
> brazillians.

Just superficial suggestions, only because it's 1st of May and WE so that better answers won't maybe come up before monday.

If all what you describe is right, then there must be something wrong with char encoding in configParser's write method. Have you had a look at it? While I hardly imagine why/how ConfigParser would limit file pathes to 7-bit ASCII...
Also, for porteguese characters, you shouldn't even need explicit encoding; they should pass through silently because they fit in an 8 bit latin charset. (I never encode french path/file names.)

Can you consider writing to file "manually" if the config file structure is simple enough? I mean ConfigParser can be a great help for /parsing/ a config file. But writing it out may well be much easier, no?

Denis
------
la vita e estrany


More information about the Tutor mailing list