-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_unicode.py
40 lines (32 loc) · 959 Bytes
/
print_unicode.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python3
import sys
import unicodedata
def print_unicode_table(words):
print("decimal hex chr {0:^40}".format("name"))
print("------- ----- --- {0:-<40}".format(""))
code = ord(" ")
end = sys.maxunicode
while code < end:
c = chr(code)
name = unicodedata.name(c, "*** unknown ***")
find=True
for word in words:
if word.lower() not in name.lower():
find=False
break
if words is None or find:
print("{0:7} {0:5X} {0:^3c} {1}".format(
code, name.title()))
code += 1
words = []
if len(sys.argv) > 1:
if sys.argv[1] in ("-h", "--help"):
print("usage: {0} [string]".format(sys.argv[0]))
words = None
else:
for word in sys.argv:
words.append(word)
words.remove(sys.argv[0])
x=len(words)
if words is not None:
print_unicode_table(words)