Why is URL Encoding Needed?
URLs can only be sent over the Internet using the ASCII character set. Because URLs often contain characters outside the ASCII set, or characters with reserved meanings (like `?`, `&`, `=`, `/`), they must be converted into a valid ASCII format.
- Reserved Characters: Characters that have special syntax meanings in URLs (e.g. `?` starts a query string, `&` separates parameters). If they are part of the actual data, they must be encoded. E.g. `&` becomes `%26`.
- Unsafe Characters: Spaces, brackets, quotes, and non-ASCII Unicode symbols are unsafe because they might be misinterpreted by browsers or mail clients. E.g., a space becomes `%20` or `+`.
Typical Percent-Encoding Reference
| Character | Percent-Encoded Value | Description |
|---|---|---|
| Space | %20 | Separator |
| / | %2F | Slash (Directory path separator) |
| ? | %3F | Question mark (Query separator) |
| & | %26 | Ampersand (Parameter separator) |
| = | %3D | Equals sign (Key-value binder) |