Html 简明教程
HTML - URL Encoding
URL 编码是一种将 URL 中不可打印的字符或有特殊含义的字符转换成一种明确无歧义且被网络浏览器和服务器普遍接受的表示形式的做法。这些字符包括:
URL encoding is the practice of translating unprintable characters or characters with special meaning within URLs to a representation that is unambiguous and universally accepted by web browsers and servers. These characters include −
-
ASCII control characters − Unprintable characters typically used for output control. Character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal). A complete encoding table is given below.
-
Non-ASCII control characters − These are characters beyond the ASCII character set of 128 characters. This range is part of the ISO-Latin character set and includes the entire "top half" of the ISO-Latin set 80-FF hex (128-255 decimal). A complete encoding table is given below.
-
Reserved characters − These are special characters such as the dollar sign, ampersand, plus, common, forward slash, colon, semi-colon, equals sign, question mark, and "at" symbol. All of these can have different meanings inside a URL so need to be encoded. A complete encoding table is given below.
-
Unsafe characters − These are space, quotation marks, less than symbol, greater than symbol, pound character, percent character, Left Curly Brace, Right Curly Brace, Pipe, Backslash, Caret, Tilde, Left Square Bracket, Right Square Bracket, Grave Accent. These character present the possibility of being misunderstood within URLs for various reasons. These characters should also always be encoded. A complete encoding table is given below.
编码符号用三个字符替换所需的字符:一个百分号和两个十六进制数字,这两个数字对应于字符在 ASCII 字符集中的位置。
The encoding notation replaces the desired character with three characters: a percent sign and two hexadecimal digits that correspond to the position of the character in the ASCII character set.
Example
最常见的特殊字符之一是空格。你无法在 URL 中直接键入一个空格。字符集中一个空格的位置是 20 十六进制。所以你可以在向服务器发送你的请求时使用 %20 代替空格。
One of the most common special characters is a white space. You can’t type a space in a URL directly. A space position in the character set is 20 hexadecimals. So you can use %20 in place of a space when passing your request to the server.
http://www.example.com/new%20pricing.htm
此 URL 实际上检索来自 www.example.com 的名为“new pricing.htm”的文档
This URL actually retrieves a document named "new pricing.htm" from the www.example.com
ASCII Control Characters Encoding
这包括字符范围 00-1F 十六进制(0-31 十进制)和 7F(127 十进制)的编码
This includes the encoding for character ranges 00-1F hex (0-31 decimal) and 7F (127 decimal)
Decimal |
Hex Value |
Character |
URL Encode |
0 |
00 |
%00 |
|
1 |
01 |
%01 |
|
2 |
02 |
%02 |
|
3 |
03 |
%03 |
|
4 |
04 |
%04 |
|
5 |
05 |
%05 |
|
6 |
06 |
%06 |
|
7 |
07 |
%07 |
|
8 |
08 |
backspace |
%08 |
9 |
09 |
tab |
%09 |
10 |
0a |
linefeed |
%0a |
11 |
0b |
%0b |
|
12 |
0c |
%0c |
|
13 |
0d |
carriage return |
%0d |
14 |
0e |
%0e |
|
15 |
0f |
%0f |
|
16 |
10 |
%10 |
|
17 |
11 |
%11 |
|
18 |
12 |
%12 |
|
19 |
13 |
%13 |
|
20 |
14 |
%14 |
|
21 |
15 |
%15 |
|
22 |
16 |
%16 |
|
23 |
17 |
%17 |
|
24 |
18 |
%18 |
|
25 |
19 |
%19 |
|
26 |
1a |
%1a |
|
27 |
1b |
%1b |
|
28 |
1c |
%1c |
|
29 |
1d |
%1d |
|
30 |
1e |
%1e |
|
31 |
1f |
%1f |
|
127 |
7f |
%7f |
Non-ASCII control characters encoding
这包括 ISO-Latin 集的整个“上半部分”,即 80-FF 十六进制(128255 十进制)的编码
This includes the encoding for the entire "top half" of the ISO-Latin set 80-FF hex (128255 decimal.)
Decimal |
Hex Value |
Character |
URL Encode |
128 |
80 |
€ |
%80 |
129 |
81 |
|
%81 |
130 |
82 |
‚ |
%82 |
131 |
83 |
ƒ |
%83 |
132 |
84 |
„ |
%84 |
133 |
85 |
… |
%85 |
134 |
86 |
† |
%86 |
135 |
87 |
‡ |
%87 |
136 |
88 |
ˆ |
%88 |
137 |
89 |
‰ |
%89 |
138 |
8a |
Š |
%8a |
139 |
8b |
‹ |
%8b |
140 |
8c |
Œ |
%8c |
141 |
8d |
|
%8d |
142 |
8e |
Ž |
%8e |
143 |
8f |
|
%8f |
144 |
90 |
|
%90 |
145 |
91 |
‘ |
%91 |
146 |
92 |
’ |
%92 |
147 |
93 |
“ |
%93 |
148 |
94 |
” |
%94 |
149 |
95 |
• |
%95 |
150 |
96 |
– |
%96 |
151 |
97 |
— |
%97 |
152 |
98 |
˜ |
%98 |
153 |
99 |
™ |
%99 |
154 |
9a |
š |
%9a |
155 |
9b |
› |
%9b |
156 |
9c |
œ |
%9c |
157 |
9d |
|
%9d |
158 |
9e |
ž |
%9e |
159 |
9f |
Ÿ |
%9f |
160 |
a0 |
%a0 |
|
161 |
a1 |
¡ |
%a1 |
162 |
a2 |
¢ |
%a2 |
163 |
a3 |
£ |
%a3 |
164 |
a4 |
¤ |
%a4 |
165 |
a5 |
¥ |
%a5 |
166 |
a6 |
¦ |
%a6 |
167 |
a7 |
§ |
%a7 |
168 |
a8 |
¨ |
%a8 |
169 |
a9 |
© |
%a9 |
170 |
aa |
ª |
%aa |
171 |
ab |
« |
%ab |
172 |
ac |
¬ |
%ac |
173 |
ad |
|
%ad |
174 |
ae |
® |
%ae |
175 |
af |
¯ |
%af |
176 |
b0 |
° |
%b0 |
177 |
b1 |
± |
%b1 |
178 |
b2 |
² |
%b2 |
179 |
b3 |
³ |
%b3 |
180 |
b4 |
´ |
%b4 |
181 |
b5 |
µ |
%b5 |
182 |
b6 |
¶ |
%b6 |
183 |
b7 |
· |
%b7 |
184 |
b8 |
¸ |
%b8 |
185 |
b9 |
¹ |
%b9 |
186 |
ba |
º |
%ba |
187 |
bb |
» |
%bb |
188 |
bc |
¼ |
%bc |
189 |
bd |
½ |
%bd |
190 |
be |
¾ |
%be |
191 |
bf |
¿ |
%bf |
192 |
c0 |
À |
%c0 |
193 |
c1 |
Á |
%c1 |
194 |
c2 |
 |
%c2 |
195 |
c3 |
à |
%c3 |
196 |
c4 |
Ä |
%c4 |
197 |
c5 |
Å |
%c5 |
198 |
c6 |
Æ |
%v6 |
199 |
c7 |
Ç |
%c7 |
200 |
c8 |
È |
%c8 |
201 |
c9 |
É |
%c9 |
202 |
ca |
Ê |
%ca |
203 |
cb |
Ë |
%cb |
204 |
cc |
Ì |
%cc |
205 |
cd |
Í |
%cd |
206 |
ce |
Î |
%ce |
207 |
cf |
Ï |
%cf |
208 |
d0 |
Ð |
%d0 |
209 |
d1 |
Ñ |
%d1 |
210 |
d2 |
Ò |
%d2 |
211 |
d3 |
Ó |
%d3 |
212 |
d4 |
Ô |
%d4 |
213 |
d5 |
Õ |
%d5 |
214 |
d6 |
Ö |
%d6 |
215 |
d7 |
× |
%d7 |
216 |
d8 |
Ø |
%d8 |
217 |
d9 |
Ù |
%d9 |
218 |
da |
Ú |
%da |
219 |
db |
Û |
%db |
220 |
dc |
Ü |
%dc |
221 |
dd |
Ý |
%dd |
222 |
de |
Þ |
%de |
223 |
df |
ß |
%df |
224 |
e0 |
à |
%e0 |
225 |
e1 |
á |
%e1 |
226 |
e2 |
â |
%e2 |
227 |
e3 |
ã |
%e3 |
228 |
e4 |
ä |
%e4 |
229 |
e5 |
å |
%e5 |
230 |
e6 |
æ |
%e6 |
231 |
e7 |
ç |
%e7 |
232 |
e8 |
è |
%e8 |
233 |
e9 |
é |
%e9 |
234 |
ea |
ê |
%ea |
235 |
eb |
ë |
%eb |
236 |
ec |
ì |
%ec |
237 |
ed |
í |
%ed |
238 |
ee |
î |
%ee |
239 |
ef |
ï |
%ef |
240 |
f0 |
ð |
%f0 |
241 |
f1 |
ñ |
%f1 |
242 |
f2 |
ò |
%f2 |
243 |
f3 |
ó |
%f3 |
244 |
f4 |
ô |
%f4 |
245 |
f5 |
õ |
%f5 |
246 |
f6 |
ö |
%f6 |
247 |
f7 |
÷ |
%f7 |
248 |
f8 |
ø |
%f8 |
249 |
f9 |
ù |
%f9 |
250 |
fa |
ú |
%fa |
251 |
fb |
û |
%fb |
252 |
fc |
ü |
%fc |
253 |
fd |
ý |
%fd |
254 |
fe |
þ |
%fe |
255 |
ff |
ÿ |
%ff |
Reserved Characters Encoding
以下是用于对保留字符进行编码的表。
Following is the table to be used to encode reserved characters.
Decimal |
Hex Value |
Char |
URL Encode |
36 |
24 |
$ |
%24 |
38 |
26 |
& |
%26 |
43 |
2b |
+ |
%2b |
44 |
2c |
, |
%2c |
47 |
2f |
/ |
%2f |
58 |
3a |
: |
%3a |
59 |
3b |
; |
%3b |
61 |
3d |
= |
%3d |
63 |
3f |
? |
%3f |
64 |
40 |
@ |
%40 |
Unsafe Characters Encoding
以下是用于对不安全字符进行编码的表。
Following is the table to be used to encode unsafe characters.
Decimal |
Hex Value |
Char |
URL Encode |
32 |
20 |
space |
%20 |
34 |
22 |
" |
%22 |
60 |
3c |
< |
%3c |
62 |
3e |
> |
%3e |
35 |
23 |
# |
%23 |
37 |
25 |
% |
%25 |
123 |
7b |
{ |
%7b |
125 |
7d |
} |
%7d |
124 |
7c |
||
%7c |
92 |
5c |
|
%5c |
94 |
5e |
^ |
%5e |
126 |
7e |
~ |
%7e |
91 |
5b |
[ |
%5b |
93 |
5d |
] |
%5d |
96 |
60 |
` |