Encoding URL characters
URLs need to be formatted with ASCII characters in order for browsers to correctly interpret them.
There are sets of characters that serve a specific purpose within a URL. For example, "/" is used to separate domains and directories and "?" is used to separate query strings.
":" | "/" | "#" | "?" | "&" | "@" | "%" | "+" | "~" | ";" | "=" | "$" | ","
If any of these characters are used within a URL for any purpose outside of what they're supposed to be used for, they'll need to be encoded. For example, this may happen when these characters form part of a URL within a query parameter ("?"):
- https://ad.atdmt.com/example.html?query1=abc:123
In this example, the colon ":" is being used within a query parameter and therefore should be encoded in order for this URL to be correctly interpreted by the browser.
As a result, the encoded version of the this URL is:
- https://ad.atdmt.com/example.html?query1=abc%3A123
Encoding involves escaping these characters followed by their hexadecimal (two-character) equivalent value, as defined within the US ASCII character set. Escaping is denoted by the percentage sign character "%".
The hex value for ":" is 3A so the complete encoded version of this character becomes %3A.
Learn more about preparing tags.
* Nguồn: Facebook