URL Encoder/Decoder

What is URL Encoding ?

A URL is composed from a limited set of characters belonging to the US-ASCII character set. These characters include digits (0-9), letters(A-Z, a-z), and a few special characters ("-", ".", "_", "~").

ASCII control characters (e.g. backspace, vertical tab, horizontal tab, line feed etc), unsafe characters like space, \, <, >, {, } etc, and any character outside the ASCII charset is not allowed to be placed directly within URLs.

So what do we do when we need to transmit any data in the URL that contain these disallowed characters? Well, we encode them!

Definition :

URL Encoding converts reserved, unsafe, and non-ASCII characters in URLs to a format that is universally accepted and understood by all web browsers and servers. It first converts the character to one or more bytes. Then each byte is represented by two hexadecimal digits preceded by a percent sign (%) - (e.g. %xy). The percent sign is used as an escape character.

URL encoding is also called percent encoding since it uses percent sign (%) as an escape character.

Example :

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

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

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