Reputation: 37
How can I print unicode strings within Python 3?
myString = 'My unicode character: \ufffd'
print(myString)
The Output should be: "My unicode character: ü"
File "C:\Program Files (x86)\Python35-32\lib\encodings\cp850.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode character '\ufffd' in position 22: character maps to
I have read lots of articles about this on Stack Exchange, but non of the answers worked.
Please help. I am really curious how to solve this really simple looking example! Thans very much in advance!
Upvotes: 1
Views: 2901
Reputation: 955
It seems that you are doing this using Windows command line.
chcp 65001
set PYTHONIOENCODING=utf-8
You can try to run above command first before running python3
. It will set the console encoder to utf-8 that can represent your data.
Upvotes: 1