URLs are used for locating resources on the internet and intranet.URL have a specific format which browers understands.Servers use the URL to locate the resource and send it to the browser.URL is a string of characters.The characters allowed in the string are:
- Numeric characters
- Some special characters
If you have a string which contains characters which are not valid in the URL then that string needs to be encoded.This is absolutely necessary since it will create problems for both browser and the server.There could be few scenarios where you would need to encode the URL:
- When the URL consists of characters which are entered by the user
- When you want to specify characters which not part of the reserved characters and are allowed in the URL.
Encoding means replacing certain characters in the unencoded string with equivalent characters.The encoded characters are preceded by % (percentage sign) followed by hexadecimal digits such as %20.
Following are some of the characters and their equivalent string representations.
|Character||Encoded UTF-8 value|