f



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

Im reading a file. But there seems to be some encoding error.

>>> f =3D open(filename)
>>> data =3D f.read()
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    data =3D f.read()
  File "C:\Python30\lib\io.py", line 1724, in read
    decoder.decode(self.buffer.read(), final=3DTrue))
  File "C:\Python30\lib\io.py", line 1295, in decode
    output =3D self.decoder.decode(input, final=3Dfinal)
  File "C:\Python30\lib\encodings\cp1252.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[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=C2=BB=C3=9D \u2021 0\u201a0 \u2021=C2=BB=C3=9D","

So what encoding value am I supposed to give ? I tried f =3D
open(filename, encoding=3D"cp1252") but still same error. I guess
Python3 auto-detects it as cp1252
--=20
Anjanesh Lekshmnarayanan
0
mail9861 (21)
1/29/2009 4:24:46 PM
comp.lang.python 77058 articles. 4 followers. Post Follow

0 Replies
2234 Views

Similar Articles

[PageSpeed] 13

Reply: