[Tutor] output not in ANSI, conversing char set to locale.getpreferredencoding()

eryksun eryksun at gmail.com
Tue Aug 14 16:42:13 CEST 2012


On Tue, Aug 14, 2012 at 10:03 AM, Peter Otten <__peter__ at web.de> wrote:
>
> You have to find out the database encoding

The character at 7 is 'ë', which is '\xc3\xab' in UTF-8. So that's
likely the db encoding.

> As you now have a bytestring again you can forget about codecs.open() which
> won't work anyway as the csv module doesn't support unicode properly in
> Python 2.x (The csv documentation has the details).

Sorry for suggesting codecs.open earlier. I looked at the source for
the _csv module, and sure enough it calls PyObject_Str(field).
Thankfully csv in 3.x has a new API.


More information about the Tutor mailing list