You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
540 B
Python
24 lines
540 B
Python
#!/usr/bin/env python3
|
|
|
|
orig = {}
|
|
with open("charmap.txt" ) as f:
|
|
for n, line in enumerate(f):
|
|
line = line.strip()
|
|
if line:
|
|
orig[n] = line
|
|
else:
|
|
print(n, "-empty-")
|
|
clist = {}
|
|
for pos, char in orig.items():
|
|
ascii = ord(char)
|
|
clist[ascii] = pos, char
|
|
print(pos, char, ascii)
|
|
|
|
for x in range(0xff):
|
|
print(x, *clist.get(x, (0, '')))
|
|
|
|
print("unsigned char charmap[] = {", end="")
|
|
for x in range(0xff):
|
|
print('{:>0}'.format(clist.get(x, (0, 0))[0]), end=", ")
|
|
print("};")
|