I\'ve never fully wrapped my head around encoding and decoding unicode to other formats (utf-8, utf-16, ascii, etc.) but I\'ve reached a wall thatis both confusing and frust
By default, the console in Microsoft Windows only displays 256 characters (cp437, of "Code page 437", the original IBM-PC 1981 extended ASCII character set) as you say in comments.
and in other side the PYTHONIOENCODING
is set to UTF-8
by default. so i think when you want to print unicode in windows you have to align sys.stdout.encoding
and PYTHONIOENCODING
with together !
also note that when you specify an encoding for your .py
file it just use it for that code and dont change the default system encoding
.
so do something like this :
import codecs
my_str='♠' # or something like my_str='\u05dd'
my_str.encode().decode('cp437')