SAX unicode and ascii parsing problem
Stefan Behnel
stefan_ml at behnel.de
Wed Dec 1 02:55:14 EST 2010
goldtech, 30.11.2010 22:15:
> Think I found it, for example:
>
> line = 'my big string'
> line.encode('ascii', 'ignore')
>
> I processed the problem strings during parsing with this and it works
> now.
That's not the right way of dealing with encodings, though. You should open
the file with a well defined encoding (using codecs.open() or io.open() in
Python >= 2.6), and then write the unicode strings into it just as you get
them.
Stefan
More information about the Python-list
mailing list