Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode error when reading RTF #42

Open
pombredanne opened this issue Sep 27, 2016 · 3 comments
Open

Unicode error when reading RTF #42

pombredanne opened this issue Sep 27, 2016 · 3 comments

Comments

@pombredanne
Copy link

When trying to read https://www.gnu.org/licenses/lgpl.rtf I get:

>>> b=Rtf15Reader.read(open('lgpl.rtf', 'rb'))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pom/tmp/local/lib/python2.7/site-packages/pyth/plugins/rtf15/reader.py", line 86, in read
    return reader.go()
  File "/home/pom/tmp/local/lib/python2.7/site-packages/pyth/plugins/rtf15/reader.py", line 109, in go
    self.parse()
  File "/home/pom/tmp/local/lib/python2.7/site-packages/pyth/plugins/rtf15/reader.py", line 143, in parse
    self.group.handle(control, digits)
  File "/home/pom/tmp/local/lib/python2.7/site-packages/pyth/plugins/rtf15/reader.py", line 402, in handle
    handler(digits)
  File "/home/pom/tmp/local/lib/python2.7/site-packages/pyth/plugins/rtf15/reader.py", line 521, in handle_ansi_escape
    char = chr(code).decode(self.charset, self.reader.errors)
UnicodeDecodeError: 'cp932' codec can't decode byte 0x81 in position 0: incomplete multibyte sequence
@pombredanne
Copy link
Author

@brendonh Are you still maintaining this repo?

@hongtaicao
Copy link

hongtaicao commented Aug 6, 2017

I got the same error when parsing the following rtf file.
00938.rtf.docx

I added the .docx extension for uploading purpose only.

log:
Traceback (most recent call last):
File "C:\test\rtf.py", line 12, in
doc = Rtf15Reader.read(open(pathname, 'r'))
File "C:\Program Files\Python27\lib\site-packages\pyth\plugins\rtf15\reader.py", line 86, in read
return reader.go()
File "C:\Program Files\Python27\lib\site-packages\pyth\plugins\rtf15\reader.py", line 109, in go
self.parse()
File "C:\Program Files\Python27\lib\site-packages\pyth\plugins\rtf15\reader.py", line 143, in parse
self.group.handle(control, digits)
File "C:\Program Files\Python27\lib\site-packages\pyth\plugins\rtf15\reader.py", line 402, in handle
handler(digits)
File "C:\Program Files\Python27\lib\site-packages\pyth\plugins\rtf15\reader.py", line 521, in handle_ansi_escape
char = chr(code).decode(self.charset, self.reader.errors)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xc8 in position 0: incomplete multibyte sequence

@alantygel
Copy link

Same here: 'cp950' codec can't decode byte 0xfa in position 0: incomplete multibyte sequence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants