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

Peter J. Holzer hjp-python at hjp.at
Sat Oct 20 08:47:28 EDT 2018


On 2018-10-20 05:24:37 -0700, pjmclenon at gmail.com wrote:
> On Saturday, October 13, 2018 at 7:24:14 PM UTC-4, MRAB wrote:
> > with open(join("docs", path), encoding="utf-8") as f:
> 
> hello MRAB and google forum

I feel somewhat excluded by this salutaton, as I'm not MRAB and I don't
read this on Google Groups, but I'll answer anyway ;-).

> i have a sort of decode error it seems now very close to the line in my script
> which you solved for my 2 previous encode errors in python 3
> 
> the error now is 
> **************
> UnicodeDecodeError; 'utf-8' can't decode byte 0xb0 in position 83064: invalid start byte

[...]

> would the solution fix be this?
> **********************
> data = f.read(), decoding = "utf-8"  #OR
> data = f.read(), decoding = "ascii" # is this the right fix or previous or both wrong??

0xB0 isn't a valid ASCII character, so you'll get a decoding error for
open(..., encoding="ascii"), too.

You will have to find out the correct encoding for your file and use
that.

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20181020/4b36a69f/attachment.sig>


More information about the Python-list mailing list