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
|
#!/usr/bin/env python
#
# Generate an asciidoc table of the six-bit encoding used in AIVDM packets.
#
# This file is Copyright (c) 2010 by the GPSD project
# BSD terms apply: see the file COPYING in the distribution root for details.
sixbits = (
"000000", "000001", "000010", "000011", "000100",
"000101", "000110", "000111", "001000", "001001",
"001010", "001011", "001100", "001101", "001110",
"001111", "010000", "010001", "010010", "010011",
"010100", "010101", "010110", "010111", "011000",
"011001", "011010", "011011", "011100", "011101",
"011110", "011111", "100000", "100001", "100010",
"100011", "100100", "100101", "100110", "100111",
"101000", "101001", "101010", "101011", "101100",
"101101", "101110", "101111", "110000", "110001",
"110010", "110011", "110100", "110101", "110110",
"110111", "111000", "111001", "111010", "111011",
"111100", "111101", "111110", "111111",
)
def asciiarmor():
print("`--------`-------`---------`-------")
print(" Char ASCII Decimal Bits")
for ch in range(ord('0'), ord('W')+1) + range(ord('`'), ord('w')+1):
n = ch - 48
if n >= 40: n -= 8
print '"%s" %3d %3d %s' % (chr(ch), ch, n, sixbits[n])
print("---------------------------------------")
if __name__ == "__main__":
asciiarmor()
|