Skip to content

Instantly share code, notes, and snippets.

@thewisenerd
Created January 25, 2022 12:29
Show Gist options
  • Save thewisenerd/02ca60a484904fcc11bb4622f9f65218 to your computer and use it in GitHub Desktop.
Save thewisenerd/02ca60a484904fcc11bb4622f9f65218 to your computer and use it in GitHub Desktop.
ASCII Table
000 0x00 NUL // Null
001 0x01 SOH // Start Of Heading
002 0x02 STX // Start Of Text
003 0x03 ETX // End Of Text
004 0x04 EOT // End Of Transmit
005 0x05 ENQ // Enquiry
006 0x06 ACK // Acknowledge
007 0x07 BEL // Bell
008 0x08 BS // Backspace
009 0x09 TAB // Horizontal Tab
010 0x0A LF // Line Feed
011 0x0B VT // Vertical Tab
012 0x0C FF // Form Feed
013 0x0D CR // Carriage Return
014 0x0E SO // Shift Out
015 0x0F SI // Shift In
016 0x10 DLE // Data Line Escape
017 0x11 DC1 // Device Control 1
018 0x12 DC2 // Device Control 2
019 0x13 DC3 // Device Control 3
020 0x14 DC4 // Device Control 4
021 0x15 NAK // Non Acknowledge
022 0x16 SYN // Synchronous Idle
023 0x17 ETB // End Transmit Block
024 0x18 CAN // Cancel
025 0x19 EM // End Of Medium
026 0x1A SUB // Substitute
027 0x1B ESC // Escape
028 0x1C FS // File Separator
029 0x1D GS // Group Separator
030 0x1E RS // Record Separator
031 0x1F US // Unit Separator
032 0x20 (space)
033 0x21 !
034 0x22 "
035 0x23 #
036 0x24 $
037 0x25 %
038 0x26 &
039 0x27 '
040 0x28 (
041 0x29 )
042 0x2A *
043 0x2B +
044 0x2C ,
045 0x2D -
046 0x2E .
047 0x2F /
048 0x30 0
049 0x31 1
050 0x32 2
051 0x33 3
052 0x34 4
053 0x35 5
054 0x36 6
055 0x37 7
056 0x38 8
057 0x39 9
058 0x3A :
059 0x3B ;
060 0x3C <
061 0x3D =
062 0x3E >
063 0x3F ?
064 0x40 @
065 0x41 A
066 0x42 B
067 0x43 C
068 0x44 D
069 0x45 E
070 0x46 F
071 0x47 G
072 0x48 H
073 0x49 I
074 0x4A J
075 0x4B K
076 0x4C L
077 0x4D M
078 0x4E N
079 0x4F O
080 0x50 P
081 0x51 Q
082 0x52 R
083 0x53 S
084 0x54 T
085 0x55 U
086 0x56 V
087 0x57 W
088 0x58 X
089 0x59 Y
090 0x5A Z
091 0x5B [
092 0x5C \
093 0x5D ]
094 0x5E ^
095 0x5F _
096 0x60 `
097 0x61 a
098 0x62 b
099 0x63 c
100 0x64 d
101 0x65 e
102 0x66 f
103 0x67 g
104 0x68 h
105 0x69 i
106 0x6A j
107 0x6B k
108 0x6C l
109 0x6D m
110 0x6E n
111 0x6F o
112 0x70 p
113 0x71 q
114 0x72 r
115 0x73 s
116 0x74 t
117 0x75 u
118 0x76 v
119 0x77 w
120 0x78 x
121 0x79 y
122 0x7A z
123 0x7B {
124 0x7C |
125 0x7D }
126 0x7E ~
127 0x7F DEL
control_chars = [
'NUL','SOH','STX','ETX','EOT','ENQ','ACK','BEL','BS','TAB','LF','VT','FF','CR','SO','SI',
'DLE','DC1','DC2','DC3','DC4','NAK','SYN','ETB','CAN','EM','SUB','ESC','FS','GS','RS','US',
]
control_desc = [
'Null','Start Of Heading','Start Of Text','End Of Text','End Of Transmit','Enquiry','Acknowledge','Bell','Backspace','Horizontal Tab','Line Feed','Vertical Tab','Form Feed','Carriage Return','Shift Out','Shift In','Data Line Escape','Device Control 1','Device Control 2','Device Control 3','Device Control 4','Non Acknowledge','Synchronous Idle','End Transmit Block','Cancel','End Of Medium','Substitute','Escape','File Separator','Group Separator','Record Separator','Unit Separator'
]
for i in range(0, 128):
desc = None
if i < len(control_chars):
render = control_chars[i]
desc = control_desc[i]
render = render.rjust(3, ' ')
elif i == 32:
render = '(space)'
elif i == 127:
render = 'DEL'
else:
render = chr(i)
if desc is not None:
print('{:03d} 0x{:0>2X} {} // {}'.format(i, i, render, desc))
else:
print('{:03d} 0x{:0>2X} {}'.format(i, i, render))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment