简体   繁体   English

如何将字符串“ \\ uFFFF”转换为Unicode?

[英]How to convert string “\uFFFF” to Unicode?

I am quite new to Javascript and easily get into trouble when dealing with string. 我是Java语言的新手,在处理字符串时很容易遇到麻烦。 I have done some research but it is difficult to get the solution and the best answer found in this site is in Java. 我已经进行了一些研究,但是很难找到解决方案,并且在此站点中找到的最佳答案是Java。 I really need your help to make it in Javascript. 我真的需要您的帮助才能使用Javascript实现。

I started with this: 我从这个开始:

xmlHttp = new XMLHttpRequest(); 
xmlHttp.open("GET", sUrl, true);
xmlHttp.overrideMimeType('text/plain; charset=utf8');
xmlHttp.send(null);

The xmlHttp.responseText contains strings like "le t\ù di ch\ào" where the \ù</b> and are Unicode characters ( ù , à ). xmlHttp.responseText包含诸如"le t\ù di ch\ào"类的字符串,其中\ù</b>是Unicode字符( ùà )。

How can I covert the xmlHttp.responseText into readable characters in Javascript? 如何将xmlHttp.responseText隐藏为Javascript中的可读字符?

Thanks to Niet the Dark Absol 's hint, I solved the problem. 感谢Niet the Dark Absol的提示,我解决了这个问题。

xmlHttp.overrideMimeType('application/json');
obj = JSON.parse(xmlHttp.responseText);

document.getElementById('Content').innerHTML = obj.data[0].name;

More info from http://www.w3schools.com/json/json_eval.asp 来自http://www.w3schools.com/json/json_eval.asp的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM