11111
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import re, sys, unicodedata as U
|
|
4 def tr(c):
|
|
5 m = re.match(r'(.*\bLATIN\b.*\bLETTER )([A-Z])\b(.*)', U.name(c, ''))
|
|
6 if m:
|
|
7 p, q, r = m.groups()
|
|
8 n = ord(q) - ord('A')
|
|
9 try:
|
|
10 return U.lookup(p + chr(ord('A') + (n + 13) % 26) + r)
|
|
11 except KeyError:
|
|
12 return c
|
|
13 return c
|
|
14
|
|
15 def tr2(c):
|
|
16 d = tr(c)
|
|
17 if d != c:
|
|
18 return d
|
|
19 else:
|
|
20 cs = [unichr(int(x, 16)) for x in U.decomposition(c).split()]
|
|
21 ds = [tr(x) for x in cs]
|
|
22 if cs != ds:
|
|
23 return u''.join(ds)
|
|
24 else:
|
|
25 return c
|
|
26
|
|
27 for c in unicode(sys.stdin.read(), 'utf8'):
|
|
28 sys.stdout.write(tr2(c).encode('utf8'))
|
|
29
|