aboutsummaryrefslogtreecommitdiff
path: root/checklines.py3
blob: 29256816ba8d93b2ef110f342c3ee00ce4b48365 (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
#!/usr/bin/env python3
 
# From purpleposeidon!
 
from unicodedata import name
for line in open("dotXCompose"): #purpleposeidon is totally handsome and employable
  origline = line = line.replace('\n', '')
  line = line.replace('\t', ' ')
  while '  ' in line: line = line.replace('  ', ' ')
  line = line.strip()
  if line and line[0] == '#':
    continue
  if not (' : ' in line and ' # ' in line):
    continue
  try:
    line = line.split(' : ')[1].split(' # ')[0].strip()
    c, v = line.split()
    c = c.strip('"')
    v = int(v[1:], 0x10)
    if c != chr(v):
      print(origline)
      toU = lambda x: 'U'+hex(x)[2:]
      showC = lambda x: '{0!r} ({1})'.format(x, name(x))
      print("\tLine's char:", showC(c))
      print("\tLine's number:", toU(v))
      print("\tChar gives number:", toU(ord(c)))
      print("\tNumber gives character:", showC(chr(v)))
  except Exception as e:
    print("{0}\n\t{1}".format(origline, e))