Created
April 6, 2016 18:37
-
-
Save 0x5742/3f941f191f58f046125949505738537e to your computer and use it in GitHub Desktop.
Unicode character viewing tool
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import unicodedata, sys | |
| def uninamenum(c): | |
| u = 'U+%04X' % ord(c) | |
| try: | |
| name = unicodedata.name(c) | |
| except: | |
| return u | |
| else: | |
| return u + ' ' + name.title() | |
| import ctypes | |
| wcwidth = ctypes.CDLL(None).wcwidth | |
| wcwidth.argtypes = [ctypes.c_wchar] | |
| def printable_char(c): | |
| return (c if wcwidth(c) >= 0 else '') | |
| def describe(chunk): | |
| return '\n'.join('%s\t%s' % (printable_char(c), uninamenum(c)) | |
| for c in chunk.rstrip('\n')) | |
| print('\n\n'.join(filter(None, map(describe, (sys.stdin if len(sys.argv) == 1 | |
| else sys.argv[1:]))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment