When I use the firefox,I found that it will encoding the Chinese characters in the address bar,which make it difficult for decode .
Exemaple:
In the js code,I have encoding the url:
location.href="http://xxx/query.html?type="+encodingURI('中文');
Then in the address bar,the firefox show me this:
http://xxx/query.html?type=中文
but,if I enter the "Enter" key in the address,which means reload this page,then the address will be changed to
http://xxx/query.html?type=%D6%D0%CE%C4
Then I can not decode the "=%D6%D0%CE%C4". Since it can not be decoded using
decodeURI('%D6%D0%CE%C4');
In fact the encodeURI("中文")="%E4%B8%AD%E6%96%87"
I wonder how does firefox do and how to decode the parameter?
Firefox doesn't behave that way for me. It's not encoding those characters in the URL when I hit enter.
By the way, the correct UTF-8 encoding of 中文
is %E4%B8%AD%E6%96%87
.
encodeURIComponent("中文");
"%E4%B8%AD%E6%96%87"
decodeURIComponent("%E4%B8%AD%E6%96%87");
"中文"
For example: http://google.com?q=中文 .
它使用的是标准的url编码,您需要确保具有正确的doctype才能显示这些字符,否则您将获得不理想的结果。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.