🔤 URL Encode / Decode
Encode and decode URLs online
📐 工作原理与说明
URL 编码把非安全字符转为百分号加两位十六进制(空格转 %20、中文按 UTF-8 逐字节转码);encodeURIComponent 编码除 A 至 Z、a 至 z、0 至 9 及减号、下划线、点、感叹号、波浪号、星号、单引号、圆括号之外的全部字符;encodeURI 保留冒号、斜杠、问号、井号、方括号、@ 等结构字符以维持完整 URL 语义;解码为逆过程,非法百分号序列应原样保留。
Formula & Standard References
| Item | Formula / Rule | Source / Standard |
|---|---|---|
| Encoding pipeline | Non-ASCII characters are first split into UTF-8 bytes, then each byte becomes %XX | RFC 3986 §2.1 / RFC 3629 |
| Decoding | A run of %XX octets is reassembled into bytes and then decoded as UTF-8 text | WHATWG URL Standard, percent-decode |
| Reserved characters | gen-delims and sub-delims carry meaning in context and must not be encoded blindly | RFC 3986 §2.2 Reserved Characters |
📌 说明
- 编码:对字符串进行 encodeURIComponent 编码。
- 解码:对字符串进行 decodeURIComponent 解码。
- 解析 URL:提取协议、主机、路径、查询参数等组成部分。