UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 10442: character maps to <undefined>

Benjamin Kaplan bsk16 at case.edu
Thu Jan 29 18:21:21 CET 2009

On Thu, Jan 29, 2009 at 12:09 PM, Anjanesh Lekshminarayanan <
mail at anjanesh.net> wrote:

> > It does auto-detect it as cp1252- look at the files in the traceback and
> > you'll see lib\encodings\cp1252.py. Since cp1252 seems to be the wrong
> > encoding, try opening it as utf-8 or latin1 and see if that fixes it.
> Thanks a lot ! utf-8 and latin1 were accepted !
> --

If you want to read the file as text, find out which encoding it actually
is. In one of those encodings, you'll probably see some nonsense characters.
If you are just looking at the file as a sequence of bytes, open the file in
binary mode rather than text. That way, you'll avoid this issue all together
(just make sure you use byte strings instead of unicode strings).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090129/39ecce4c/attachment.html>

More information about the Python-list mailing list