forked from standardebooks/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unicode-names
executable file
·28 lines (19 loc) · 879 Bytes
/
unicode-names
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
#!/usr/bin/python3
import argparse
import sys
import unicodedata
def main():
parser = argparse.ArgumentParser(description="Display Unicode code points, descriptions, and links to more details for each character in a string. Useful for differentiating between different flavors of spaces, dashes, and invisible characters like word joiners.")
parser.add_argument("strings", metavar="STRING", nargs="*", help="a Unicode string")
args = parser.parse_args()
lines = []
if not sys.stdin.isatty():
for line in sys.stdin:
lines.append(line.rstrip("\n"))
for line in args.strings:
lines.append(line)
for line in lines:
for character in line:
print(character + "\tU+{:04X}".format(ord(character)) + "\t" + unicodedata.name(character) + "\t" + "http://unicode.org/cldr/utility/character.jsp?a={:04X}".format(ord(character)))
if __name__ == "__main__":
main()