Skip to content

Instantly share code, notes, and snippets.

@ankr
Last active August 29, 2015 14:05
Show Gist options
  • Save ankr/4f7ead1e1a8efce52de3 to your computer and use it in GitHub Desktop.
Save ankr/4f7ead1e1a8efce52de3 to your computer and use it in GitHub Desktop.

ASCII TABLE

Dec Hex Oct Binary Char Description
0000 0000 0000 00000000 NUL Null Character
0001 0001 0001 00000001 SOH Start of Header
0002 0002 0002 00000010 STX Start of Text
0003 0003 0003 00000011 ETX End of Text
0004 0004 0004 00000100 EOT End of Transmission
0005 0005 0005 00000101 ENQ Enquiry
0006 0006 0006 00000110 ACK Acknowledgement
0007 0007 0007 00000111 BEL Bell
0008 0008 0010 00001000 BS Backspace
0009 0009 0011 00001001 HT Horizontal Tab
0010 000A 0012 00001010 LF Line Feed
0011 000B 0013 00001011 VT Vertical Tab
0012 000C 0014 00001100 FF Form Feed
0013 000D 0015 00001101 CR Cariage Return
0014 000E 0016 00001110 SO Shift Out
0015 000F 0017 00001111 SI Shift In
0016 0010 0020 00010000 DLE Data Link Escape
0017 0011 0021 00010001 DC1 Device Control 1 (XON)
0018 0012 0022 00010010 DC2 Device Control 2
0019 0013 0023 00010011 DC3 Device Control 3 (XOFF)
0020 0014 0024 00010100 DC4 Device Control 4
0021 0015 0025 00010101 NAK Negative Acknowledgement
0022 0016 0026 00010110 SYN Synchronous Idle
0023 0017 0027 00010111 ETB End of Trans. Block
0024 0018 0030 00011000 CAN Cancel
0025 0019 0031 00011001 EM End of Medium
0026 001A 0032 00011010 SUB Substitute
0027 001B 0033 00011011 ESC Escape
0028 001C 0034 00011100 FS File Separator
0029 001D 0035 00011101 GS Group Separator
0030 001E 0036 00011110 RS Request to Send / Rec Sep
0031 001F 0037 00011111 US Unit Separator
0032 0020 0040 00100000 SP Space
0033 0021 0041 00100001 !
0034 0022 0042 00100010 "
0035 0023 0043 00100011 #
0036 0024 0044 00100100 $
0037 0025 0045 00100101 %
0038 0026 0046 00100110 &
0039 0027 0047 00100111 '
0040 0028 0050 00101000 (
0041 0029 0051 00101001 )
0042 002A 0052 00101010 *
0043 002B 0053 00101011 +
0044 002C 0054 00101100 ,
0045 002D 0055 00101101 -
0046 002E 0056 00101110 .
0047 002F 0057 00101111 /
0048 0030 0060 00110000 0
0049 0031 0061 00110001 1
0050 0032 0062 00110010 2
0051 0033 0063 00110011 3
0052 0034 0064 00110100 4
0053 0035 0065 00110101 5
0054 0036 0066 00110110 6
0055 0037 0067 00110111 7
0056 0038 0070 00111000 8
0057 0039 0071 00111001 9
0058 003A 0072 00111010 :
0059 003B 0073 00111011 ;
0060 003C 0074 00111100 <
0061 003D 0075 00111101 =
0062 003E 0076 00111110 >
0063 003F 0077 00111111 ?
0064 0040 0100 01000000 @
0065 0041 0101 01000001 A
0066 0042 0102 01000010 B
0067 0043 0103 01000011 C
0068 0044 0104 01000100 D
0069 0045 0105 01000101 E
0070 0046 0106 01000110 F
0071 0047 0107 01000111 G
0072 0048 0110 01001000 H
0073 0049 0111 01001001 I
0074 004A 0112 01001010 J
0075 004B 0113 01001011 K
0076 004C 0114 01001100 L
0077 004D 0115 01001101 M
0078 004E 0116 01001110 N
0079 004F 0117 01001111 O
0080 0050 0120 01010000 P
0081 0051 0121 01010001 Q
0082 0052 0122 01010010 R
0083 0053 0123 01010011 S
0084 0054 0124 01010100 T
0085 0055 0125 01010101 U
0086 0056 0126 01010110 V
0087 0057 0127 01010111 W
0088 0058 0130 01011000 X
0089 0059 0131 01011001 Y
0090 005A 0132 01011010 Z
0091 005B 0133 01011011 [
0092 005C 0134 01011100 \
0093 005D 0135 01011101 ]
0094 005E 0136 01011110 ^
0095 005F 0137 01011111 _
0096 0060 0140 01100000 `
0097 0061 0141 01100001 a
0098 0062 0142 01100010 b
0099 0063 0143 01100011 c
0100 0064 0144 01100100 d
0101 0065 0145 01100101 e
0102 0066 0146 01100110 f
0103 0067 0147 01100111 g
0104 0068 0150 01101000 h
0105 0069 0151 01101001 i
0106 006A 0152 01101010 j
0107 006B 0153 01101011 k
0108 006C 0154 01101100 l
0109 006D 0155 01101101 m
0110 006E 0156 01101110 n
0111 006F 0157 01101111 o
0112 0070 0160 01110000 p
0113 0071 0161 01110001 q
0114 0072 0162 01110010 r
0115 0073 0163 01110011 s
0116 0074 0164 01110100 t
0117 0075 0165 01110101 u
0118 0076 0166 01110110 v
0119 0077 0167 01110111 w
0120 0078 0170 01111000 x
0121 0079 0171 01111001 y
0122 007A 0172 01111010 z
0123 007B 0173 01111011 {
0124 007C 0174 01111100
0125 007D 0175 01111101 }
0126 007E 0176 01111110 ~
0127 007F 0177 01111111 DEL Delete
<?php
// 0 to 32 are invisible characters
// Here are some hardcoded value names for them
$values = [
['NUL' => 'Null Character'],
['SOH' => 'Start of Header'],
['STX' => 'Start of Text'],
['ETX' => 'End of Text'],
['EOT' => 'End of Transmission'],
['ENQ' => 'Enquiry'],
['ACK' => 'Acknowledgement'],
['BEL' => 'Bell'],
['BS' => 'Backspace'],
['HT' => 'Horizontal Tab'],
['LF' => 'Line Feed'],
['VT' => 'Vertical Tab'],
['FF' => 'Form Feed'],
['CR' => 'Cariage Return'],
['SO' => 'Shift Out'],
['SI' => 'Shift In'],
['DLE' => 'Data Link Escape'],
['DC1' => 'Device Control 1 (XON)'],
['DC2' => 'Device Control 2'],
['DC3' => 'Device Control 3 (XOFF)'],
['DC4' => 'Device Control 4'],
['NAK' => 'Negative Acknowledgement'],
['SYN' => 'Synchronous Idle'],
['ETB' => 'End of Trans. Block'],
['CAN' => 'Cancel'],
['EM' => 'End of Medium'],
['SUB' => 'Substitute'],
['ESC' => 'Escape'],
['FS' => 'File Separator'],
['GS' => 'Group Separator'],
['RS' => 'Request to Send / Rec Sep'],
['US' => 'Unit Separator'],
['SP' => 'Space'],
// Extras that need explanation
124 => ['|' => 'Pipe'],
127 => ['DEL' => 'Delete']
];
echo '| Dec | Hex | Oct | Binary | Char | Description |' . "\n";
echo '|------|------|------|----------|-------|----------------------------------|' . "\n";
for ($i = 0; $i < 128; $i++) {
$char = chr($i);
$description = '';
if (isset($values[$i])) {
$data = $values[$i];
$char = key($data);
$description = current($data);
}
printf("| %04d | %s | %04d | %08d | %s | %s |\n",
$i,
str_pad(strtoupper(dechex($i)), 4, '0', STR_PAD_LEFT),
decoct($i),
decbin($i),
str_pad($char, 5, ' ', STR_PAD_BOTH),
str_pad($description, 32)
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment