SBTI Personality Test: A 15-Dimension Character Analysis Beyond MBTI
12 min
When you copy a URL containing Chinese characters, they often transform into %XX codes. What's behind this? This article explains URL encoding from the ground up.
You've probably seen URLs like this:
``
https://www.baidu.com/s?wd=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD
`
That %XX string is "人工智能" (artificial intelligence) URL-encoded. This is called Percent-encoding — or simply URL encoding.
Why URL Encoding Exists
URL spec (RFC 3986) allows only:
Unreserved characters: letters (A–Z, a–z), digits (0–9), -, _, ., ~
Reserved characters (structural): :, /, ?, #, [, ], @, etc.
Everything else — Chinese characters, spaces, special symbols — must be percent-encoded.
How URL Encoding Works
1. Get the UTF-8 byte sequence of the character
2. Represent each byte as % + two uppercase hex digits
Example — "中" (Chinese for "middle"):
UTF-8: 0xE4, 0xB8, 0xAD
URL encoded: %E4%B8%AD
Space (ASCII 0x20): → %20 (or + in form data)
encodeURI vs encodeURIComponent
encodeURI() — encodes a complete URL, leaving structural characters (:, /, ?, &, =, #) untouched:
`javascript
encodeURI('https://woshiit.com/search?q=人工智能&page=1')
// → 'https://woshiit.com/search?q=%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD&page=1'
`
encodeURIComponent() — encodes a URL component (e.g. a query param value), including structural characters:
`javascript
encodeURIComponent('https://woshiit.com/search?q=人工智能')
// → 'https%3A%2F%2Fwoshiit.com%2Fsearch%3Fq%3D%E4%BA%BA%E5%B7%A5%E6%99%BA%E8%83%BD'
`
|---|---|
Scenario Use
Encode a full URL encodeURI()
Encode a query param value encodeURIComponent()
Build URL with dynamic params encodeURIComponent()
Common Scenarios
API requests with dynamic params:
`javascript
const keyword = '人工智能';
const url = https://api.example.com/search?q=${encodeURIComponent(keyword)};
`
SVG in CSS: SVG strings contain <, >, # — must be percent-encoded inside url()`.
Need to encode or decode a URL quickly? Use our URL Encode/Decode tool — supports full URL and URI component modes, and handles already-encoded strings intelligently.
woshiit 技术团队
woshiit AI Navigation · Original Content
12 min
8 min
7 min
8 min