1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26"""
cat a list of Unicode codepoints to get a string of actual text.
Each line should be one codepoint in U+XXXX format.
"""
import sys
for line in sys.stdin:
if line.startswith(('U+', 'u+')):
_, hx = line.strip().split('+')
n = int(hx, base=16)
try:
char = unichr(n)
out = char.encode('utf-8')
except NameError:
out = chr(n)
else:
out = line
try:
sys.stdout.write(out)
except UnicodeEncodeError as e:
sys.stderr.write('\n' + str(e) + '\n')
print