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

MRAB python at mrabarnett.plus.com
Sat Oct 20 11:39:12 EDT 2018


On 2018-10-20 13:47, Peter J. Holzer wrote:
> 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 ;-).
> 
Well, I am MRAB, and I'm not on Google Groups either! :-)

>> 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.
> 
I concur; it appears that the file isn't encoded in UTF-8, or ASCII 
either (valid ASCII is also valid UTF-8).



More information about the Python-list mailing list