Tutorials Point


  HTML Tutorial
  HTML References
  HTML Tools
  HTML Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

HTML URL Encoding


previous next AddThis Social Bookmark Button


Advertisements

URL encoding is the practice of translating unprintable characters or characters with special meaning within URLs to a representation that is unambiguous and universally accepted by web browsers and servers. These characters include:

  • ASCII control characters - Unprintable characters typically used for output control. Character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal). A complete encoding table is given below.

  • Non-ASCII control characters - These are characters beyond the ASCII character set of 128 characters. This range is part of the ISO-Latin character set and ncludes the entire "top half" of the ISO-Latin set 80-FF hex (128-255 decimal). A complete encoding table is given below.

  • Reserved characters - These are special characters such as the dollar sign, ampersand, plus, common, forward slash, colon, semi-colon, equals sign, question mark, and "at" symbol. All of these can have different meanings inside a URL so need to be encoded. A complete encoding table is given below.

  • Unsafe characters - These are space, quotation marks, less than symbol, greater than symbol, pound character, percent character, Left Curly Brace, Right Curly Brace , Pipe, Backslash, Caret, Tilde, Left Square Bracket , Right Square Bracket, Grave Accent. These character present the possibility of being misunderstood within URLs for various reasons. These characters should also always be encoded. A complete encoding table is given below.

The encoding notation replaces the desired character with three characters: a percent sign and two hexadecimal digits whose correspond to the position of the character in the ASCII character set.

Example:

One of the most common special characters is the space. You can't type a space in a URL directly. A space position in the character set is 20 hexadecimal. So you can use %20 in place a space when passing your request to the server.

http://www.example.com/new%20pricing.html

This URL actually retrieves a document named new pricing.html from the www.example.com

ASCII control characters encoding

This includes the encoding for character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal)

DecimalHex ValueCharacterURL Encode
000 %00
101 %01
202 %02
303 %03
404 %04
505 %05
606 %06
707 %07
808backspace%08
909tab%09
100alinefeed%0a
110b %0b
120c %0c
130dcarriage return%0d
140e %0e
150f %0f
1610 %10
1711 %11
1812 %12
1913 %13
2014 %14
2115 %15
2216 %16
2317 %17
2418 %18
2519 %19
261a %1a
271b %1b
281c %1c
291d %1d
301e %1e
311f %1f
1277f %7f

Non-ASCII control characters encoding

This includes the encoding for the entire "top half" of the ISO-Latin set 80-FF hex (128-255 decimal.)

DecimalHex ValueCharacterURL Encode
12880%80
12981%81
13082%82
13183ƒ%83
13284%84
13385%85
13486%86
13587%87
13688ˆ%88
13789%89
1388aŠ%8a
1398b%8b
1408cŒ%8c
1418d%8d
1428eŽ%8e
1438f%8f
14490%90
14591%91
14692%92
14793%93
14894%94
14995%95
15096%96
15197%97
15298˜%98
15399%99
1549aš%9a
1559b%9b
1569cœ%9c
1579d%9d
1589ež%9e
1599fŸ%9f
160a0 %a0
161a1¡%a1
162a2¢%a2
163a3£%a3
164a4¤%a4
165a5¥%a5
166a6¦%a6
167a7§%a7
168a8¨%a8
169a9©%a9
170aaª%aa
171ab«%ab
172ac¬%ac
173ad­%ad
174ae®%ae
175af¯%af
176b0°%b0
177b1±%b1
178b2²%b2
179b3³%b3
180b4´%b4
181b5µ%b5
182b6%b6
183b7·%b7
184b8¸%b8
185b9¹%b9
186baº%ba
187bb»%bb
188bc¼%bc
189bd½%bd
190be¾%be
191bf¿%bf
192c0À%c0
193c1Á%c1
194c2Â%c2
195c3Ã%c3
196c4Ä%c4
197c5Å%c5
198c6Æ%v6
199c7Ç%c7
200c8È%c8
201c9É%c9
202caÊ%ca
203cbË%cb
204ccÌ%cc
205cdÍ%cd
206ceÎ%ce
207cfÏ%cf
208d0Ð%d0
209d1Ñ%d1
210d2Ò%d2
211d3Ó%d3
212d4Ô%d4
213d5Õ%d5
214d6Ö%d6
215d7×%d7
216d8Ø%d8
217d9Ù%d9
218daÚ%da
219dbÛ%db
220dcÜ%dc
221ddÝ%dd
222deÞ%de
223dfß%df
224e0à%e0
225e1á%e1
226e2â%e2
227e3ã%e3
228e4ä%e4
229e5å%e5
230e6æ%e6
231e7ç%e7
232e8è%e8
233e9é%e9
234eaê%ea
235ebë%eb
236ecì%ec
237edí%ed
238eeî%ee
239efï%ef
240f0ð%f0
241f1ñ%f1
242f2ò%f2
243f3ó%f3
244f4ô%f4
245f5õ%f5
246f6ö%f6
247f7÷%f7
248f8ø%f8
249f9ù%f9
250faú%fa
251fbû%fb
252fcü%fc
253fdý%fd
254feþ%fe
255ffÿ%ff

Reserved characters encoding

Following is the table to be used to encode reserved characters.

DecimalHex ValueCharURL Encode
3624$%24
3826&%26
432b+%2b
442c,%2c
472f/%2f
583a:%3a
593b;%3b
613d=%3d
633f?%3f
6440@%40

Unsafe characters encoding

Following is the table to be used to encode unsafe characters.

DecimalHex ValueCharURL Encode
3220space%20
3422"%22
603c<%3c
623e>%3e
3523#%23
3725%%25
1237b{%7b
1257d}%7d
1247c|%7c
925c\%5c
945e^%5e
1267e~%7e
915b[%5b
935d]%5d
9660`%60


previous next Printer Friendly

Advertisements


  

Advertisements