Reputation: 1
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?
Upvotes: 0
Views: 3230
Reputation: 27880
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=中文.
Upvotes: 4
Reputation: 4501
It's using standard url encoding, you need to make sure you have the correct doctype to display those characters, otherwise you will get unsatisfactory results.
Upvotes: 0