aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/genhextable.py
blob: 2a45a9e83b18322442ab79aa062f5da24e17e655 (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
import sys

HexTable={
    '0' : 0,  '1' : 1,
    '2' : 2,  '3' : 3,
    '4' : 4,  '5' : 5,
    '6' : 6,  '7' : 7,
    '8' : 8,  '9' : 9,
    'A' : 10, 'B' : 11,
    'C' : 12, 'D' : 13,
    'E' : 14, 'F' : 15,
    'a' : 10, 'b' : 11,
    'c' : 12, 'd' : 13,
    'e' : 14, 'f' : 15,

    ' ' : -1, ',' : -1,
    '}' : -1, '\n' : -1,
    '\t' : -1
}

OutHexTable=[0]*256

for Char,Val in HexTable.iteritems():
  OutHexTable[ord(Char)]=Val
  
print "static const short hexTable[256] = {"
i=0
for Item in OutHexTable:
  if i==0:
    PreFix="   "
  elif i%16 == 0:
    PreFix="\n  ,"
  else:
    PreFix=", "
  i+=1
  Val="%d"%Item
  if len(Val)==1: Val = " "+Val
  sys.stdout.write("%s%s"%(PreFix,Val))
print "\n};"