• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2import sys
3
4def name(i):
5    if i < 0x20:
6        return \
7            ['NUL ', 'SOH ', 'STX ', 'ETX ', 'EOT ', 'ENQ ', 'ACK ', 'BEL ',
8             'BS  ', 'HT  ', 'LF  ', 'VT  ', 'FF  ', 'CR  ', 'SO  ', 'SI  ',
9             'DLE ', 'DC1 ', 'DC2 ', 'DC3 ', 'DC4 ', 'NAK ', 'SYN ', 'ETB ',
10             'CAN ', 'EM  ', 'SUB ', 'ESC ', 'FS  ', 'GS  ', 'RS  ', 'US  '][i]
11    elif i == 0x7f:
12        return 'DEL '
13
14for i in range(256):
15    if chr(i) == ' ':
16        sys.stdout.write('{} /* SPC  */, '.format(i))
17    elif chr(i) == '\t':
18        sys.stdout.write('{} /* HT   */, '.format(i))
19    elif 'A' <= chr(i) and chr(i) <= 'Z':
20        sys.stdout.write('{} /* {}    */, '.format(i - ord('A') + ord('a'), chr(i)))
21    elif (0x21 <= i and i < 0x7f):
22        sys.stdout.write('{} /* {}    */, '.format(i, chr(i)))
23    elif 0x80 <= i:
24        sys.stdout.write('{} /* {} */, '.format(i, hex(i)))
25    elif 0 == i:
26        sys.stdout.write('{} /* NUL  */, '.format(i))
27    else:
28        sys.stdout.write('{} /* {} */, '.format(i, name(i)))
29    if (i + 1)%4 == 0:
30        sys.stdout.write('\n')
31