Skip to content

Commit eabe9fb

Browse files
committed
Initial checkin.
1 parent 2a79dd9 commit eabe9fb

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

python/ppt/ascii.py

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
"""
2+
usage: ascii.py [-h] [-l]
3+
4+
Prints an ASCII table similar to "man ascii"
5+
6+
options:
7+
-h, --help show this help message and exit
8+
-l, --long Long version of the ASCII table.
9+
"""
10+
11+
import sys
12+
import argparse
13+
14+
long_text = r"""
15+
Dec Hex Char Dec Hex Char
16+
────────────────────────────────────────────────────────────
17+
0 00 NUL '\0' (null character) 64 40 @
18+
1 01 SOH (start of heading) 65 41 A
19+
2 02 STX (start of text) 66 42 B
20+
3 03 ETX (end of text) 67 43 C
21+
4 04 EOT (end of transmission) 68 44 D
22+
5 05 ENQ (enquiry) 69 45 E
23+
6 06 ACK (acknowledge) 70 46 F
24+
7 07 BEL '\a' (bell) 71 47 G
25+
8 08 BS '\b' (backspace) 72 48 H
26+
9 09 HT '\t' (horizontal tab) 73 49 I
27+
10 0A LF '\n' (new line) 74 4A J
28+
11 0B VT '\v' (vertical tab) 75 4B K
29+
12 0C FF '\f' (form feed) 76 4C L
30+
13 0D CR '\r' (carriage ret) 77 4D M
31+
14 0E SO (shift out) 78 4E N
32+
15 0F SI (shift in) 79 4F O
33+
16 10 DLE (data link escape) 80 50 P
34+
17 11 DC1 (device control 1) 81 51 Q
35+
18 12 DC2 (device control 2) 82 52 R
36+
19 13 DC3 (device control 3) 83 53 S
37+
20 14 DC4 (device control 4) 84 54 T
38+
21 15 NAK (negative ack.) 85 55 U
39+
22 16 SYN (synchronous idle) 86 56 V
40+
23 17 ETB (end of trans. blk) 87 57 W
41+
24 18 CAN (cancel) 88 58 X
42+
25 19 EM (end of medium) 89 59 Y
43+
26 1A SUB (substitute) 90 5A Z
44+
27 1B ESC (escape) 91 5B [
45+
28 1C FS (file separator) 92 5C \ '\\'
46+
29 1D GS (group separator) 93 5D ]
47+
30 1E RS (record separator) 94 5E ^
48+
31 1F US (unit separator) 95 5F _
49+
32 20 SPACE 96 60 `
50+
33 21 ! 97 61 a
51+
34 22 " 98 62 b
52+
35 23 # 99 63 c
53+
36 24 $ 100 64 d
54+
37 25 % 101 65 e
55+
38 26 & 102 66 f
56+
39 27 ' 103 67 g
57+
40 28 ( 104 68 h
58+
41 29 ) 105 69 i
59+
42 2A * 106 6A j
60+
43 2B + 107 6B k
61+
44 2C , 108 6C l
62+
45 2D - 109 6D m
63+
46 2E . 110 6E n
64+
47 2F / 111 6F o
65+
48 30 0 112 70 p
66+
49 31 1 113 71 q
67+
50 32 2 114 72 r
68+
51 33 3 115 73 s
69+
52 34 4 116 74 t
70+
53 35 5 117 75 u
71+
54 36 6 118 76 v
72+
55 37 7 119 77 w
73+
56 38 8 120 78 x
74+
57 39 9 121 79 y
75+
58 3A : 122 7A z
76+
59 3B ; 123 7B {
77+
60 3C < 124 7C |
78+
61 3D = 125 7D }
79+
62 3E > 126 7E ~
80+
63 3F ? 127 7F DEL"""
81+
82+
short_text = r"""
83+
2 3 4 5 6 7
84+
-------------
85+
0: 0 @ P ` p
86+
1: ! 1 A Q a q
87+
2: " 2 B R b r
88+
3: # 3 C S c s
89+
4: $ 4 D T d t
90+
5: % 5 E U e u
91+
6: & 6 F V f v
92+
7: ' 7 G W g w
93+
8: ( 8 H X h x
94+
9: ) 9 I Y i y
95+
A: * : J Z j z
96+
B: + ; K [ k {
97+
C: , < L \ l |
98+
D: - = M ] m }
99+
E: . > N ^ n ~
100+
F: / ? O _ o DEL"""
101+
102+
103+
def main(options):
104+
if options.long:
105+
print(long_text)
106+
else:
107+
print(short_text)
108+
return 0
109+
110+
111+
def get_parser():
112+
parser = argparse.ArgumentParser(
113+
description="Prints an ASCII table similar to \"man ascii\"")
114+
parser.add_argument(
115+
'-l',
116+
'--long',
117+
dest='long',
118+
help='Long version of the ASCII table.',
119+
action='store_true',
120+
default=False)
121+
return parser
122+
123+
124+
if __name__ == '__main__':
125+
parser = get_parser()
126+
options = parser.parse_args()
127+
sys.exit(main(options))

0 commit comments

Comments
 (0)