编码URI(空格等),不编码非ASCII字符 [英] encode URI (spaces etc.), without encode non-ASCII characters
本文介绍了编码URI(空格等),不编码非ASCII字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用escape/encodeURI/encodeURIComponent编码URI时,
它编码特殊字符(例如?[]&")和所有非ASCII字符.
When I use escape/encodeURI/encodeURIComponent to encode URI,
it's encoding special characters (like "? [ ] &" ), and all non-ASCII characters.
我希望链接看起来像:
http:/site.com/?tm=ДОБРОЕ**%20**УТРО
代替:
http:/site.com/?tm=%u0414%u041E%u0411%u0420%u041E%u0415**%20**%u0423%u0422%u0420%u041E
我的问题:
- 是否需要对非ASCII编码?
- 是否有仅编码特殊字符的函数? (不包含非ASCII)
推荐答案
- 是的.
- 不.
在 http://www.w3.org/Addressing/URL/5_BNF.html中可以阅读:
国家"和标点"字符不会出现在任何作品中,因此可能不会出现在URL中.
The "national" and "punctuation" characters do not appear in any productions and therefore may not appear in URLs.
这篇关于编码URI(空格等),不编码非ASCII字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文