For more background, I found the text from this session at the most recent PyCon interesting. It's a nice overview of Unicode in Python.
"Pragmatic Unicode or How Do I Stop the Pain?" -- Ned Batchelder
http://nedbatchelder.com/text/unipain.html
> -----Original Message-----
> From: Code for Libraries [mailto:[log in to unmask]] On Behalf Of
> Brian Kennison
> Sent: Friday, March 09, 2012 9:17 AM
> To: [log in to unmask]
> Subject: Re: [CODE4LIB] Q.: MARC8 vs. MARC/Unicode and pymarc and
> misencoded III records
>
> On Mar 8, 2012, at 1:46 PM, Terray, James wrote:
>
> > UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 9:
> ordinal not in range(128)
>
>
> Hello everyone,
>
> I just ran into this the other day when trying to write to a file. I searched the
> documentation and found this:
>
> fp = codecs.open("dc.csv", mode="w", encoding="utf-8")
>
> This opens a file that is utf-8 aware and it let me write the file. Doesn't answer
> your question about the encoding but it will let you save the record.
>
> --
> Brian Kennison
> Western Connecticut State University
|