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
160�240A0
161�241A1
162�242A2
163�243A3
164�244A4
165�245A5
166�246A6
167�247A7
168�250A8
169�251A9
170�252AA
171�253AB
172�254AC
173�255AD
174�256AE
175�257AF
176�260B0
177�261B1
178�262B2
179�263B3
180�264B4
181�265B5
182�266B6
183�267B7
184�270B8
185�271B9
186�272BA
187�273BB
188�274BC
189�275BD
190�276BE
191�277BF
192�300C0
193�301C1
194�302C2
195�303C3
196�304C4
197�305C5
198�306C6
199�307C7
200�310C8
201�311C9
202�312CA
203�313CB
204�314CC
205�315CD
206�316CE
207�317CF
208�320D0
209�321D1
210�322D2
211�323D3
212�324D4
213�325D5
214�326D6
215�327D7
216�330D8
217�331D9
218�332DA
219�333DB
220�334DC
221�335DD
222�336DE
223�337DF
224�340E0
225�341E1
226�342E2
227�343E3
228�344E4
229�345E5
230�346E6
231�347E7
232�350E8
233�351E9
234�352EA
235�353EB
236�354EC
237�355ED
238�356EE
239�357EF
240�360F0
241�361F1
242�362F2
243�363F3
244�364F4
245�365F5
246�366F6
247�367F7
248�370F8
249�371F9
250�372FA
251�373FB
252�374FC
253�375FD
254�376FE
255�377FF

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