<html> <p>URI 编码</p> <p>URI 中的一些字符被保留来用作分隔符, 比如 `/`, `:` 用来指明协议, `?` 用来分割 path 和 querystring, `&` 用来分割 querystring 中的不同参数, `=` 用来分割每个参数的键和值. 其它还有很多.</p> <p>那么问题来了, 如果我们想在 URI 中正常使用这些保留字符该怎么用呢? 比如说我们就是想在参数得值中包含 `&` 字符:</p> <p><a href="http://127.0.0.1:8080/index.php?key1=value1&key2=value2&value3">http://127.0.0.1:8080/index.php?key1=value1&key2=value2&value3</a></p> <p>如果不做其他处理, 就这样直接请求这个 URI 的话, `key2=value2&value3` 将会被当做两个参数, 其中一个参数键为 key2, 值为 value2, 另一个参数键为 value3, 没有值.</p> <p>那么怎么办呢, RFC3986 已经给出了解决方法, 就是在我们想正常使用这些特殊字符的时候用 `%HH` 的方式编码它们.</p> <h4>其它需要编码的字符</h4> <p>RFC3986 中定义了保留字符, 这些字符必须被编码; 还定义了非保留字符, 这些字符完全没必要被编码, 但是你硬要编也可以. 最后剩下的字符不属于这两类, 但是也可能需要被编码. 比如 `%` 本身, 因为 `%` 被做编码的前缀了, 所以如果我们的数据中要包含 `%` 的话必须也对它编码.</p> <h4>关于空格</h4> <p>关于空格为什么需要被编码, 可以看这里: </p> <p><a href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm">http://www.blooberry.com/indexdot/html/topics/urlencoding.htm</a></p> <p>空格字符在 RFC3986 中规定是应该编码成 `%20` 的, 但是在 `application/x-www-form-urlencode` 这种内容类型中是被编码成 `+` 的. (但是仅限于 querystring 或者 post data: <a href="http://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20">http://stackoverflow.com/questions/2678551/when-to-encode-space-to-plus-or-20</a>)</p> </html>
post_id | 67,520,274 |
---|---|
author | cifer |
permlink | uri |
category | cn-programming |
json_metadata | {"links":["http:\/\/127.0.0.1:8080\/index.php?key1=value1&key2=value2&value3","http:\/\/www.blooberry.com\/indexdot\/html\/topics\/urlencoding.htm","http:\/\/stackoverflow.com\/questions\/2678551\/when-to-encode-space-to-plus-or-20"],"format":"html","app":"steemit\/0.1","tags":["cn-programming","programming","cn","cn-reader"]} |
created | 2018-12-17 06:22:21 |
last_update | 2018-12-17 06:22:21 |
depth | 0 |
children | 1 |
net_rshares | 6,571,619,099,418 |
last_payout | 2018-12-24 06:22:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 2.900 SBD |
curator_payout_value | 0.906 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 1,259 |
author_reputation | 7,963,630,681,040 |
root_title | "关于 URI 编码" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
abit | 0 | 644,190,207,511 | 100% | ||
adm | 0 | 5,554,442,032,028 | 30% | ||
jademont | 0 | 87,127,826,366 | 20% | ||
bukiland | 0 | 2,668,705,799 | 0.81% | ||
sudutpandang | 0 | 3,899,139,790 | 35% | ||
elviento | 0 | 527,818,510 | 0.71% | ||
mrstaf | 0 | 1,727,025,865 | 50% | ||
khunfarang | 0 | 208,862,276 | 50% | ||
khunpoom | 0 | 102,539,086 | 25% | ||
britcoins | 0 | 2,846,209,726 | 100% | ||
idx | 0 | 20,141,439,299 | 100% | ||
reinikaerrant | 0 | 14,525,184,901 | 27% | ||
cifer | 0 | 48,023,376,362 | 100% | ||
atimk23 | 0 | 4,696,328,403 | 100% | ||
accelerator | 0 | 18,164,792,562 | 1.29% | ||
apasia.tech | 0 | 13,669,260,159 | 100% | ||
xiaoshancun | 0 | 2,185,073,095 | 100% | ||
steembet.asia | 0 | 458,001,488 | 100% | ||
kimchi-king | 0 | 1,224,849,164 | 50% | ||
steemtaker | 0 | 1,093,662,576 | 1% | ||
zmx | 0 | 3,940,060 | 10% | ||
cnbuddy | 0 | 10,852,710,187 | 1% | ||
open-asset | 0 | 209,522,979 | 50% | ||
lebin | 0 | 37,233,275,269 | 5% | ||
coindzs | 0 | 6,003,772,902 | 100% | ||
neexal | 0 | 122,167,462 | 50% | ||
freerolll | 0 | 312,678,562 | 100% | ||
mahaw | 0 | 8,897,098,885 | 100% | ||
effofex | 0 | 71,303,028 | 0.64% | ||
irak | 0 | 204,104,860 | 100% | ||
camillesteemer | 0 | -154,373,475 | -100% | ||
hackettm21 | 0 | 522,666,120 | 100% | ||
abcor | 0 | 3,270,172,178 | 0.4% | ||
goosencat | 0 | 555,800,896 | 100% | ||
mrandreas | 0 | 202,248,133 | 50% | ||
dianation | 0 | 190,122,366 | 50% | ||
hasim5556 | 0 | 7,505,522,430 | 100% | ||
abduljalil.mbo | 0 | 91,215,330 | 5% | ||
stewedmango | 0 | 520,349,065 | 100% | ||
elianton | 0 | 520,803,204 | 100% | ||
digital-jesus | 0 | 208,315,622 | 50% | ||
svlasov1984 | 0 | 524,342,538 | 100% | ||
devsup | 0 | 2,737,773,030 | 0.69% | ||
aple | 0 | 5,378,185,403 | 100% | ||
ganeshkadam9503 | 0 | 1,434,448,675 | 100% | ||
nfc | 0 | 22,611,022,023 | 3% | ||
steemexpress | 0 | 920,448,562 | 1.81% | ||
stmpay | 0 | 6,544,663,021 | 2.02% | ||
eduardkasy | 0 | 524,357,208 | 100% | ||
behaveskaters | 0 | 524,361,005 | 100% | ||
surebat | 0 | 526,435,008 | 100% | ||
charbodge | 0 | 524,360,705 | 100% | ||
apimasses | 0 | 524,300,985 | 100% | ||
phatima | 0 | 2,957,452,788 | 3% | ||
whitebot | 0 | 19,350,914,561 | 1% | ||
steem.create | 0 | 1,210,023,061 | 2.5% | ||
luna777 | 0 | 864,121,320 | 2.4% | ||
goodshepherd | 0 | 1,822,927,121 | 10% | ||
mbappe | 0 | 1,064,783,524 | 2.5% | ||
hamsa.quality | 0 | 1,332,647,542 | 2.5% | ||
xrp.trail | 0 | 975,780,309 | 2.5% |
I 'm Myanmar. I want to fiiendship you.
post_id | 67,530,845 |
---|---|
author | mahaw |
permlink | re-cifer-uri-20181217t122253417z |
category | cn-programming |
json_metadata | {"app":"steemit\/0.1","tags":["cn-programming"]} |
created | 2018-12-17 12:22:45 |
last_update | 2018-12-17 12:22:45 |
depth | 1 |
children | 0 |
net_rshares | 0 |
last_payout | 2018-12-24 12:22:45 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 39 |
author_reputation | 7,300,176,045,008 |
root_title | "关于 URI 编码" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |