HTML: ASCII Character Codes
The table below presents all ASCII characters with codes from 32-127 and 160-255. The missing characters (0-27 and 128-159) are 'control characters' and not normally suited for output in HTML. The 'Entity' column gives the equivalent HTML character entity - where one exists.
If you're looking for a way to encode text - for protecting email links for example - you can use this form to encode a short string:
For other types of encoding in JavaScript or PHP refer to the article Escaping Special Characters.
HTML Character Codes and Entities
This table is dynamically generated.
Decimal | Symbol | Entity | Octal | Hex |
---|---|---|---|---|
32 | 40 | 20 | ||
33 | ! | 41 | 21 | |
34 | " | " | 42 | 22 |
35 | # | 43 | 23 | |
36 | $ | 44 | 24 | |
37 | % | 45 | 25 | |
38 | & | & | 46 | 26 |
39 | ' | 47 | 27 | |
40 | ( | 50 | 28 | |
41 | ) | 51 | 29 | |
42 | * | 52 | 2A | |
43 | + | 53 | 2B | |
44 | , | 54 | 2C | |
45 | - | 55 | 2D | |
46 | . | 56 | 2E | |
47 | / | 57 | 2F | |
48 | 0 | 60 | 30 | |
49 | 1 | 61 | 31 | |
50 | 2 | 62 | 32 | |
51 | 3 | 63 | 33 | |
52 | 4 | 64 | 34 | |
53 | 5 | 65 | 35 | |
54 | 6 | 66 | 36 | |
55 | 7 | 67 | 37 | |
56 | 8 | 70 | 38 | |
57 | 9 | 71 | 39 | |
58 | : | 72 | 3A | |
59 | ; | 73 | 3B | |
60 | < | < | 74 | 3C |
61 | = | 75 | 3D | |
62 | > | > | 76 | 3E |
63 | ? | 77 | 3F | |
64 | @ | 100 | 40 | |
65 | A | 101 | 41 | |
66 | B | 102 | 42 | |
67 | C | 103 | 43 | |
68 | D | 104 | 44 | |
69 | E | 105 | 45 | |
70 | F | 106 | 46 | |
71 | G | 107 | 47 | |
72 | H | 110 | 48 | |
73 | I | 111 | 49 | |
74 | J | 112 | 4A | |
75 | K | 113 | 4B | |
76 | L | 114 | 4C | |
77 | M | 115 | 4D | |
78 | N | 116 | 4E | |
79 | O | 117 | 4F | |
80 | P | 120 | 50 | |
81 | Q | 121 | 51 | |
82 | R | 122 | 52 | |
83 | S | 123 | 53 | |
84 | T | 124 | 54 | |
85 | U | 125 | 55 | |
86 | V | 126 | 56 | |
87 | W | 127 | 57 | |
88 | X | 130 | 58 | |
89 | Y | 131 | 59 | |
90 | Z | 132 | 5A | |
91 | [ | 133 | 5B | |
92 | \ | 134 | 5C | |
93 | ] | 135 | 5D | |
94 | ^ | 136 | 5E | |
95 | _ | 137 | 5F | |
96 | ` | 140 | 60 | |
97 | a | 141 | 61 | |
98 | b | 142 | 62 | |
99 | c | 143 | 63 | |
100 | d | 144 | 64 | |
101 | e | 145 | 65 | |
102 | f | 146 | 66 | |
103 | g | 147 | 67 | |
104 | h | 150 | 68 | |
105 | i | 151 | 69 | |
106 | j | 152 | 6A | |
107 | k | 153 | 6B | |
108 | l | 154 | 6C | |
109 | m | 155 | 6D | |
110 | n | 156 | 6E | |
111 | o | 157 | 6F | |
112 | p | 160 | 70 | |
113 | q | 161 | 71 | |
114 | r | 162 | 72 | |
115 | s | 163 | 73 | |
116 | t | 164 | 74 | |
117 | u | 165 | 75 | |
118 | v | 166 | 76 | |
119 | w | 167 | 77 | |
120 | x | 170 | 78 | |
121 | y | 171 | 79 | |
122 | z | 172 | 7A | |
123 | { | 173 | 7B | |
124 | | | 174 | 7C | |
125 | } | 175 | 7D | |
126 | ~ | 176 | 7E | |
127 | | 177 | 7F |
Decimal | Symbol | Entity | Octal | Hex |
---|---|---|---|---|
160 | 240 | A0 | ||
161 | 241 | A1 | ||
162 | 242 | A2 | ||
163 | 243 | A3 | ||
164 | 244 | A4 | ||
165 | 245 | A5 | ||
166 | 246 | A6 | ||
167 | 247 | A7 | ||
168 | 250 | A8 | ||
169 | 251 | A9 | ||
170 | 252 | AA | ||
171 | 253 | AB | ||
172 | 254 | AC | ||
173 | 255 | AD | ||
174 | 256 | AE | ||
175 | 257 | AF | ||
176 | 260 | B0 | ||
177 | 261 | B1 | ||
178 | 262 | B2 | ||
179 | 263 | B3 | ||
180 | 264 | B4 | ||
181 | 265 | B5 | ||
182 | 266 | B6 | ||
183 | 267 | B7 | ||
184 | 270 | B8 | ||
185 | 271 | B9 | ||
186 | 272 | BA | ||
187 | 273 | BB | ||
188 | 274 | BC | ||
189 | 275 | BD | ||
190 | 276 | BE | ||
191 | 277 | BF | ||
192 | 300 | C0 | ||
193 | 301 | C1 | ||
194 | 302 | C2 | ||
195 | 303 | C3 | ||
196 | 304 | C4 | ||
197 | 305 | C5 | ||
198 | 306 | C6 | ||
199 | 307 | C7 | ||
200 | 310 | C8 | ||
201 | 311 | C9 | ||
202 | 312 | CA | ||
203 | 313 | CB | ||
204 | 314 | CC | ||
205 | 315 | CD | ||
206 | 316 | CE | ||
207 | 317 | CF | ||
208 | 320 | D0 | ||
209 | 321 | D1 | ||
210 | 322 | D2 | ||
211 | 323 | D3 | ||
212 | 324 | D4 | ||
213 | 325 | D5 | ||
214 | 326 | D6 | ||
215 | 327 | D7 | ||
216 | 330 | D8 | ||
217 | 331 | D9 | ||
218 | 332 | DA | ||
219 | 333 | DB | ||
220 | 334 | DC | ||
221 | 335 | DD | ||
222 | 336 | DE | ||
223 | 337 | DF | ||
224 | 340 | E0 | ||
225 | 341 | E1 | ||
226 | 342 | E2 | ||
227 | 343 | E3 | ||
228 | 344 | E4 | ||
229 | 345 | E5 | ||
230 | 346 | E6 | ||
231 | 347 | E7 | ||
232 | 350 | E8 | ||
233 | 351 | E9 | ||
234 | 352 | EA | ||
235 | 353 | EB | ||
236 | 354 | EC | ||
237 | 355 | ED | ||
238 | 356 | EE | ||
239 | 357 | EF | ||
240 | 360 | F0 | ||
241 | 361 | F1 | ||
242 | 362 | F2 | ||
243 | 363 | F3 | ||
244 | 364 | F4 | ||
245 | 365 | F5 | ||
246 | 366 | F6 | ||
247 | 367 | F7 | ||
248 | 370 | F8 | ||
249 | 371 | F9 | ||
250 | 372 | FA | ||
251 | 373 | FB | ||
252 | 374 | FC | ||
253 | 375 | FD | ||
254 | 376 | FE | ||
255 | 377 | FF |
For details on non-ASCII characters supported in HTML follow the link under References below.
So why do we need all these different ways of referencing the same characters? The Decimal values are rarely used, but Octal codes turn up in various programming languages and the Hex values in URL-encoded strings (%20 represents a space for example). In HTML content the Symbol is used except where a proper Character Entity is available.
For more information on encoding special characters see the related article linked below.
Common Windows-1251 Character Codes
If your data has been corrupted with Windows-specific characters such as: smart quotes, ellipses, dashes and non-breaking spaces, the following list might be useful:
Decimal | Octal | Description | Plain Text Alternative |
---|---|---|---|
133 | \205 | ELLIPSIS | ... |
145 | \221 | HIGH 6 SINGLE QUOTE | ' |
146 | \222 | HIGH 9 SINGLE QUOTE | ' |
147 | \223 | HIGH 6 DOUBLE QUOTE | " |
148 | \224 | HIGH 9 DOUBLE QUOTE | " |
149 | \225 | LARGE CENTERED DOT | * |
150 | \226 | EN DASH | - |
151 | \227 | EM DASH | - or -- |
160 | \240 | NO-BREAK SPACE | (space) |
Other replacement values are also possible including various valid HTML entities (see above) or multibyte characters.
The reason for the \ in front of the Octal code for these characters is so that we can use them in regular expressions as shown here:
$output = mb_eregi_replace("\205", "...", $input);
You might find this necessary when converting data to UTF-8 or other multibyte character formats. For non-multibyte formats you can use the regular preg_replace or ereg_replace functions instead as there's no danger of corrupting the text by accidentally replacing one byte of a multibyte character.
References
Send a message to The Art of Web:
press <Esc> or click outside this box to close