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

When sending unicode message, throw encoding exception #78

Closed
liqiangsu opened this issue Nov 4, 2016 · 2 comments
Closed

When sending unicode message, throw encoding exception #78

liqiangsu opened this issue Nov 4, 2016 · 2 comments

Comments

@liqiangsu
Copy link

Python 3.4 64bit Winows 10
Although the message was sent successfully, the program throws an exception as following:

Traceback (most recent call last):
sent = client.send(friend.uid, u"\u4e00")
File "C:\Python34\lib\site-packages\fbchat\client.py", line 292, in send
print(data)
File "C:\Python34\lib\encodings\cp850.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 731-743: character maps to

@dstelzer
Copy link

This is actually a limitation your terminal's output encoding. Python tries to print out the message for debugging purposes, but can't find a way to print \u4e00 to a Windows terminal. Changing your output encoding (or turning debugging off) should fix it.

@afonsocarlos
Copy link
Contributor

That happened to me when I was creating my chat. I used windows 8 at that time, but as @dstelzer said that's a problem with the cmd. All you have to do is changing encoding on print.
I fixed it like so: fbchat-terminal/chat.py.

@madsmtm madsmtm closed this as completed May 10, 2017
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

4 participants