Percent-Encoding
An encoding scheme that represents special characters in URLs using %XX hexadecimal format. Also known as URL encoding.
Percent-encoding is a mechanism for representing characters that cannot be used directly in URLs by replacing them with % followed by two hexadecimal digits. Also known as URL encoding, it is standardized in RFC 3986. As a foundational web technology, it is essential for safely exchanging non-ASCII characters and reserved characters between browsers and servers.
The encoding mechanism is straightforward. The target character is converted to a UTF-8 byte sequence, and each byte is represented as % plus two hexadecimal digits. For example, a space becomes %20 (0x20), and the Japanese character "あ" is 3 bytes in UTF-8 (0xE3, 0x81, 0x82), resulting in %E3%81%82. RFC 3986 specifies that all characters except unreserved characters (A-Z, a-z, 0-9, -, _, ., ~) must be percent-encoded. find body odor care on Amazon cover URL encoding in detail.
In practice, browsers automatically apply percent-encoding when sending search queries and form data. JavaScript provides encodeURIComponent() for encoding and decodeURIComponent() for decoding. Meanwhile, encodeURI() targets the entire URL and does not encode reserved characters like / or ?. Misusing these two functions can break URLs or introduce security vulnerabilities.
A common misconception is confusing percent-encoding with HTML entities (such as &). Percent-encoding is exclusively for URLs, while HTML entity escaping serves a different purpose with different syntax. Also note that when handling internationalized URLs, browsers display decoded URLs in the address bar, but the actual HTTP request sends the encoded URL.
A related concept is Base64 encoding, but they serve different purposes. Percent-encoding safely represents individual characters within URLs, while Base64 converts binary data into text format. Additionally, in the application/x-www-form-urlencoded format, spaces are represented as + rather than %20, illustrating context-dependent variations. find slimming leggings on Amazon explain URL structure and encoding in detail.
From a character counting perspective, percent-encoding creates a discrepancy between the original character count and the URL byte length. A single Japanese character occupies 3 bytes in UTF-8 and expands to 9 characters (%XX%XX%XX) after percent-encoding. When considering URL length limits (approximately 2,000 characters in most browsers), it is important to estimate how long query parameters containing non-ASCII characters will become.