So I have been trying to print in my terminal using Python the following Unicode characters:
def printUnicode():
print(u"\u2b1c")
print(u"\u1f7e8")
print(u"\u1f7e9")
However, this is my output: https://i.stack.imgur.com/pY9lc.png.
Even though I checked that I was using UTF-8 (chcp=65001), I do not why I cannot show those characters. Idk if there is something wrong my PC configuration, the code or it just impossible to print them in windows cmd.
CodePudding user response:
Maybe you have wrong escape sequences in your string literals:
import unicodedata # access to the Unicode Character Database
def check_unicode(s):
print(len(s), s)
for char in s:
print( char, '{:04x}'.format( ord(char)),
unicodedata.category( char),
unicodedata.name( char, '(unknown)') )
Output:
check_unicode( u"\u2b1c\u1f7e8\u1f7e9") # original string literals
5 ⬜89 ⬜ 2b1c So WHITE LARGE SQUARE 1f7e Cn (unknown) 8 0038 Nd DIGIT EIGHT 1f7e Cn (unknown) 9 0039 Nd DIGIT NINE
check_unicode( u"\u2b1c\U0001f7e8\U0001f7e9") # adjusted string literals
3 ⬜