skip to content

HTML: ASCII Character Codes

The table below presents all ASCII characters with codes from 32-127 and 160-255. The missing characters (0-31 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.

Simple ASCII encoding

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:

Text to be HTML-encoded:
Output:

For other types of encoding in JavaScript or PHP refer to the article Escaping Special Characters. Encoding is handled by PHP using an Ajax request triggered on keyup.

HTML Character Codes and Entities

The following table is dynamically generated to show all characters from 32 to 255:

DecimalSymbolEntityOctalHex
32 4020
33!4121
34""4222
35#4323
36$4424
37%4525
38&&4626
39''4727
40(5028
41)5129
42*522A
43+532B
44,542C
45-552D
46.562E
47/572F
4806030
4916131
5026232
5136333
5246434
5356535
5466636
5576737
5687038
5797139
58:723A
59;733B
60<&lt;743C
61=753D
62>&gt;763E
63?773F
64@10040
65A10141
66B10242
67C10343
68D10444
69E10545
70F10646
71G10747
72H11048
73I11149
74J1124A
75K1134B
76L1144C
77M1154D
78N1164E
79O1174F
80P12050
81Q12151
82R12252
83S12353
84T12454
85U12555
86V12656
87W12757
88X13058
89Y13159
90Z1325A
91[1335B
92\1345C
93]1355D
94^1365E
95_1375F
96`14060
97a14161
98b14262
99c14363
100d14464
101e14565
102f14666
103g14767
104h15068
105i15169
106j1526A
107k1536B
108l1546C
109m1556D
110n1566E
111o1576F
112p16070
113q16171
114r16272
115s16373
116t16474
117u16575
118v16676
119w16777
120x17078
121y17179
122z1727A
123{1737B
124|1747C
125}1757D
126~1767E
1271777F
DecimalSymbolEntityOctalHex
160240A0
161241A1
162242A2
163243A3
164244A4
165245A5
166246A6
167247A7
168250A8
169251A9
170252AA
171253AB
172254AC
173255AD
174256AE
175257AF
176260B0
177261B1
178262B2
179263B3
180264B4
181265B5
182266B6
183267B7
184270B8
185271B9
186272BA
187273BB
188274BC
189275BD
190276BE
191277BF
192300C0
193301C1
194302C2
195303C3
196304C4
197305C5
198306C6
199307C7
200310C8
201311C9
202312CA
203313CB
204314CC
205315CD
206316CE
207317CF
208320D0
209321D1
210322D2
211323D3
212324D4
213325D5
214326D6
215327D7
216330D8
217331D9
218332DA
219333DB
220334DC
221335DD
222336DE
223337DF
224340E0
225341E1
226342E2
227343E3
228344E4
229345E5
230346E6
231347E7
232350E8
233351E9
234352EA
235353EB
236354EC
237355ED
238356EE
239357EF
240360F0
241361F1
242362F2
243363F3
244364F4
245365F5
246366F6
247367F7
248370F8
249371F9
250372FA
251373FB
252374FC
253375FD
254376FE
255377FF

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 representing a space character for example).

In HTML mark-up the Symbol is used except where a proper Character Entity is available - for characters that have their own meaning in HTML such as angled brackets and quotes.

For more information on encoding special characters see the related article linked below.

Common Windows-1251 Character Codes

If your data has been polluted with Windows-specific characters such as smart quotes, ellipses, dashes and non-breaking spaces, the following list might be useful:

DecimalOctalDescriptionPlain Text Alternative
133\205ELLIPSIS...
145\221HIGH 6 SINGLE QUOTE'
146\222HIGH 9 SINGLE QUOTE'
147\223HIGH 6 DOUBLE QUOTE"
148\224HIGH 9 DOUBLE QUOTE"
149\225LARGE CENTERED DOT*
150\226EN DASH-
151\227EM DASH- or --
160\240NO-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:

<?PHP $output = mb_eregi_replace("\205", "...", $input); ?>

You might find this necessary when converting data to UTF-8 or other multibyte character formats to avoid replacing one byte of a multibyte character with something else and corrupting the text.

For non-multibyte formats you can use the regular preg_replace or ereg_replace functions instead as there's no danger of corruption.

References

< HTML

Post your comment or question
top