编码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  

我的问题:

  1. 是否需要对非ASCII编码?
  2. 是否有仅编码特殊字符的函数? (不包含非ASCII)

  1. 是的.
  2. 不.

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.