Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print a variable that contains a unicode character?

print u'\u0D05'
a = '\u0D05'
print a

print a gives \u0D05 as output but I want to print the unicode character it represents, which is . How can I achieve this?

like image 781
chris Avatar asked May 15 '13 07:05

chris


1 Answers

The \u escape is not meaningful inside a non-unicode string. You need to do a = u'\u0D05'.

If you're saying you're getting the string from somewhere else and need to interpret unicode escapes in it, then do print a.decode('unicode-escape')

like image 64
BrenBarn Avatar answered Sep 28 '22 04:09

BrenBarn