Why can't “decodeURIComponent” or “decodeURI” decode “hello+world” to “hello world” in JavaScript?
本问题已经有最佳答案,请猛点这里访问。
据此:
http://en.wikipedia.org/wiki/Query_string#URL_encoding
""是有效的URL编码令牌。
如果是,为什么
如果""有效,那么肯定有JavaScript中的内置函数可以将" hello world"转换为" hello world"吗?
The
decodeURIComponent function computes a new version of aURI in which each escape sequence and UTF-8 encoding of the sort that might be introduced by theencodeURIComponent function is replaced with the character that it represents.
并且
(与
If"+" is valid, surely, there has to be a built-in function in JavaScript that can convert"hello+world" to"hello world"?
当然有:
1 | "hello+world".replace(/\\+/g, ' '); |
因为