← Back to Blog
Tech Basics2026-03-25 · 6 min read

The Complete Guide to URL Encoding: Why Chinese Characters Become %E4%B8%AD

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.

# URL# 编码# Web开发# HTTP

The Problem

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'

`

|---|---|

ScenarioUse
Encode a full URLencodeURI()
Encode a query param valueencodeURIComponent()
Build URL with dynamic paramsencodeURIComponent()

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()`.

Online Tool

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.

W

woshiit 技术团队

woshiit AI Navigation · Original Content

More Articles

Tech Sharing

SBTI Personality Test: A 15-Dimension Character Analysis Beyond MBTI

12 min

AI Tools

NüWa.skill: Distilling the Minds of Legends — Deep Conversations with Jobs & Musk via AI

8 min

Tech Basics

What is Base64 Encoding? Principles, Use Cases & Online Converter

7 min

Security

What is MD5? A Deep Dive into the MD5 Hashing Algorithm and Its Security

8 min