Mercurial > repo
view bin/unicode @ 4515:ab2d8a9d1432
<fizzie> sed -i -e \'s/import sys/import re\\nimport sys/\' -e \'s/map(unicodedata.lookup/map(l/\' -e \'s/try:/def l(c): m = re.match(\'\\\'\'(?:U+)?([0-9a-f]{4})$\'\\\'\', c); return unicodedata.lookup(c) if m is None else unichr(int(m.group(1),16))\\ntry:/\' bin/unicode
author | HackBot |
---|---|
date | Fri, 07 Mar 2014 11:03:21 +0000 |
parents | 49ab5b2e2ebf |
children | 7efc6d484fe6 |
line wrap: on
line source
#!/usr/bin/env python # -*- encoding: utf-8 -*- import re import sys import unicodedata def l(c): m = re.match('(?:U+)?([0-9a-f]{4})$', c); return unicodedata.lookup(c) if m is None else unichr(int(m.group(1),16)) try: print u''.join(map(l, sys.argv[1:])).encode('utf-8') except KeyError: print u'Unknown character.'