Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in

Reply
Thread Tools

UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in

 
 
Anjanesh Lekshminarayanan
Guest
Posts: n/a
 
      01-29-2009
Im reading a file. But there seems to be some encoding error.

>>> f = open(filename)
>>> data = f.read()

Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
data = f.read()
File "C:\Python30\lib\io.py", line 1724, in read
decoder.decode(self.buffer.read(), final=True))
File "C:\Python30\lib\io.py", line 1295, in decode
output = self.decoder.decode(input, final=final)
File "C:\Python30\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_t able)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position
10442: character maps to <undefined>

The string at position 10442 is something like this :
"query":"0 1»Ý \u2021 0\u201a0 \u2021»Ý","

So what encoding value am I supposed to give ? I tried f =
open(filename, encoding="cp1252") but still same error. I guess
Python3 auto-detects it as cp1252
--
Anjanesh Lekshmnarayanan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in Anjanesh Lekshminarayanan Python 0 02-27-2009 03:51 AM
Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in John Machin Python 0 01-30-2009 01:22 AM
Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in John Machin Python 0 01-29-2009 09:19 PM
Re: UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in Benjamin Peterson Python 0 01-29-2009 08:25 PM
UnicodeDecodeError: 'ascii' codec can't decode byte 0xa0 in position 10: ordinal not in range(128) Robin Siebler Python 4 10-08-2004 08:03 PM



Advertisments