我有一个简单的xml:
<?xml version="1.0" encoding="utf-8"?>
<category><title>Привет!</title></category>
当我从云代码(parse.com)中得到它时,如下所示:
...
Parse.Cloud.httpRequest({
url: 'http://path_to_xml/my_file.xml',
headers: {
'Content-Type': 'text/xml; charset=utf-8'
},
success: function(httpResponse) {
console.log(httpResponse.text);
}
...
在日志中我看到:
<?xml version="1.0" encoding="utf-8"?>
<category><title>ÐÑивеÑ!</title></category>
Xml文件采用UTF-8编码。这并不是日志的问题,因为当我把httpResponse.text放在对象的字符串中时,我看到了同样的问题。
可能是parse.com不支持UTF-8?
谢谢!
好的,问题是西里尔字母使用ISO-8859-5,所以你在utf8中转换,它是不可逆的。尝试声明<?xml version="1.0" encoding="ISO-8859-5"?>
并查看结果。