• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2import sys
3
4def name(i):
5    if i < 0x21:
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  ',
11             'SPC '][i]
12    elif i == 0x7f:
13        return 'DEL '
14
15for i in range(256):
16    if chr(i) in [
17        "-", ".", "_", "~",
18        "!", "$", "&", "'", "(", ")",
19        "*", "+", ",", ";", "=",
20        "%", "@", ":", "[", "]"] or\
21        ('0' <= chr(i) and chr(i) <= '9') or \
22        ('A' <= chr(i) and chr(i) <= 'Z') or \
23        ('a' <= chr(i) and chr(i) <= 'z'):
24        sys.stdout.write('1 /* {}    */, '.format(chr(i)))
25    elif (0x21 <= i and i < 0x7f):
26        sys.stdout.write('0 /* {}    */, '.format(chr(i)))
27    elif 0x80 <= i:
28        sys.stdout.write('0 /* {} */, '.format(hex(i)))
29    else:
30        sys.stdout.write('0 /* {} */, '.format(name(i)))
31    if (i + 1)%4 == 0:
32        sys.stdout.write('\n')
33