summaryrefslogtreecommitdiff
path: root/bin/ud
blob: a1a50acdea15437df10184f961d7951c1eb735e9 (plain)
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
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python3

# unidump version 0.1.1
# made by ubq323 in the year 2021
# please use this software for GOOD, not for EVIL

import unicodedata
import sys

uniquify = True
arg=""
args = sys.argv[1:]
while len(args) > 0:
    arg = args.pop(0)
    if arg[0] != '-' or arg == "--":
        break
    if arg == "-a":
        uniquify = False
        arg = ""


s = arg+" ".join(args)

if len(s) == 0:
    s = sys.stdin.read()

def row(c):
    try:
        name = unicodedata.name(c).rjust(50)
    except ValueError:
        name = "?"*50

    number = ("U+"+hex(ord(c))[2:].zfill(4)).rjust(7).upper()

    to_c = c
    if c == '\n':
        to_c = ' '

    
        
    return f"{to_c} | {unicodedata.category(c)} | {name} | {number}"

seen = set()
for c in s:
    if uniquify:
        if c in seen:
            continue
        seen.add(c)
    print(row(c))