我只是不明白,但这是我的情况。decodeURIComponent既能正常工作又不能同时工作?
我有这样的和平代码:
someFunction: function(content){
content = content.substr(19005,24);
console.log('content is: '+content);
content = decodeURIComponent(content);
console.log(typeof content, content);
var string = '\u0430\u0437\u0443\u0439';
string = decodeURIComponent(string);
console.log(typeof string, string);
}
而当我在我的Node.js服务器上运行,这将返回这个“不正常”的结果:
content is: \u0430\u0437\u0443\u0439
string \u0430\u0437\u0443\u0439 // but should be "string азуй" as below
string азуй
那么,它是如何实际可能??
1)相同的内容
2)相同的变量类型
3)相同(decodeURIComponent)函数
- 但不同的结果???
P.S.我看到的唯一区别是content
和string
变量的起源。但这是否起作用?
的[?我如何解码与忽略Unicode字符串(可能的复制http://stackoverflow.com/questions/7885096/how-do-i-decode -a-string-with-escaped-unicode) –
它不重复,因为我没有意识到我在'content'中有双重转义 –