How do I encode and decode this data to write to a file?
Ned Batchelder
ned at nedbatchelder.com
Wed May 1 19:36:19 EDT 2013
On 4/29/2013 5:47 AM, cl at isbd.net wrote:
> If I understand correctly the encode() is saying that it can't
> understand the data in the html because there's a character 0xc3 in it.
> I *think* this means that the é is encoded in UTF-8 already in the
> incoming data stream (should be as my system is wholly UTF-8 as far as I
> know and I created the directory name).
>
> So how do I change the code so I don't get the error? Do I just
> decode() the data first and then encode() it?
>
BTW, I did a presentation at PyCon 2012 that many people have found
helpful: Pragmatic Unicode, or, How Do I Stop the Pain:
http://nedbatchelder.com/text/unipain.html . It explains the principles
at work here.
--Ned.
More information about the Python-list
mailing list