HTML URL Encoding
URL encoding converts characters into a format that can be transmitted over the Internet.
Why URL Encode?
URLs can only be sent over the Internet using the ASCII character-set. Since URLs often contain characters outside the ASCII set (like spaces, or special characters like #, ?, &), the URL has to be converted into a valid ASCII format. URL encoding, also known as percent-encoding, replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.
Commonly Encoded Characters
| Character | Encoded Value |
|---|---|
| (space) | %20 |
/ | %2F |
? | %3F |
# | %23 |
& | %26 |
For example, if you wanted to search for "c++ tutorials" on a search engine, the URL might look like this:
html
https://www.google.com/search?q=c%2B%2B%20tutorialsTest Yourself with an Exercise
What is the URL-encoded representation of a space character?