短.be

Percent-Encoding

Sep 18, 2025 · About 1 min read

URL Shortening

Percent-encoding is the specific encoding mechanism used in URLs where each unsafe or reserved character is replaced by a percent sign (%) followed by two hexadecimal digits. This is the formal name for what is commonly called URL encoding. The term comes from the percent sign that prefixes each encoded character sequence.

The encoding process converts each byte of a character's UTF-8 representation into the %HH format. For single-byte ASCII characters, this produces one percent-encoded triplet. For multi-byte Unicode characters, multiple triplets are generated. For example, the Japanese character for "short" would be encoded as a series of percent-encoded bytes representing its UTF-8 encoding. Character encoding books on Amazon explain these concepts.

In practice, percent-encoding is handled automatically by web browsers, HTTP libraries, and URL shortening services. However, developers must understand it to correctly construct URLs programmatically, especially when building query strings with user-supplied values or handling internationalized domain names.

A common source of bugs is the difference between encodeURI() and encodeURIComponent() in JavaScript. The former encodes a complete URI and preserves structural characters like slashes and colons, while the latter encodes individual URI components and encodes those characters as well. Using the wrong function leads to malformed URLs. JavaScript programming books on Amazon cover these distinctions.

Related Terms

Ready to create a short URL?

Shorten a URL for Free