简体   繁体   中英

How to convert string “\uFFFF” to Unicode?

I am quite new to Javascript and easily get into trouble when dealing with string. I have done some research but it is difficult to get the solution and the best answer found in this site is in Java. I really need your help to make it in 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 ( ù , à ).

How can I covert the xmlHttp.responseText into readable characters in Javascript?

Thanks to Niet the Dark Absol 's hint, I solved the problem.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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