I want to print some unicode characters but u\'\\u1000\'
up to u\'\\u1099\'
. This doesn\'t work:
for i in range(1000,1100):
s=unico
Try the following:
for i in range(1000, 1100):
print i, unichr(i)
unichr is the function you are looking for - it takes a number and returns the Unicode character for that point.
for i in range(1000, 1100):
print i, unichr(i)
You'll want to use the unichr() builtin function:
for i in range(1000,1100):
print i, unichr(i)
Note that in Python 3, just chr() will suffice.
if you'd like to print the characters corresponding to an arbitrary unicode range, you can use the following (python 3)
unicode_range = ('4E00', '9FFF') # (CJK Unified Ideographs)
characters = []
for unicode_character in range(int(unicode_range[0], 16), int(unicode_range[1], 16)):
characters.append(chr(unicode_character))
Use unichr:
s = unichr(i)
From the documentation:
unichr(i)
Return the Unicode string of one character whose Unicode code is the integer i. For example, unichr(97) returns the string u'a'.
One might appreciate this php-cli version:
It is using html entities and UTF8 decoding.
Recent version of XTERM and others terminals supports unicode chars pretty nicely :)
php -r 'for ($x = 0; $x < 255000; $x++) {echo html_entity_decode("&#".$x.";",ENT_NOQUOTES,"UTF-8");}'