哪些字元需要urlencode編碼?具體怎麼處理?

來源:互聯網
上載者:User

標籤:style   color   使用   width   amp   table   

哪些字元需要urlencode編碼?具體怎麼處理?
JS用escape()/encodeURI()/encodeURIComponent()方法編碼,用unescape()/decodeURI()/ecodeURIComponent()解碼.

escape()/encodeURI()/encodeURIComponent()的區別:
encodeURI()不編碼82個字元!#$&‘()*+-./:;[email protected]_~0-9a-zA-Z
encodeURIComponent()不編碼71個字元! ‘()*-._~0-9a-zA-Z
escape()不編碼69個字元*+-./@_0-9a-zA-Z

如果發送頁面和接收頁面的charset是一樣的,只需要用escape()即可,如果發送頁面是gb2312,而接收頁面是utf-9,就要用encodeURI()/encodeURIComponent(),他們的區別在於,後者編碼的字元更多.如果要傳遞內容而非地址欄參數,請使用encodeURIComponent().

PHP用urlencode()不編碼,用urldecode()解碼.或者用rawurlencode()編碼,用rawurldecode()解碼
區別在於rawurlencode()編碼的字元更多,包括除-_.以外的所有字元,而urlencode()只編碼-_. 之外的非字母非數字字元.特殊字元地址欄編碼錶

 

空格 %20
! %21
# %23
$ %24
% %25
& %26
%27
( %28
) %29
* %2A
+ %2B
, %2C
. %2E
/ %2F
: %3A
; %3B
= %3D
? %3F
@ %40
[ %5B
\ %5C
] %5D

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.