I have a page which includes escaped Unicode characters. (For example the characters 漢字 are escaped as \u6F22\u5B57). This page shows how you can use the unescape() method to convert the escaped \u6F22\u5B57 to 漢字. I have a method that converts all of the Unicode escaped characters, but it is not very fast.
function DecodeAllUnicodeCharacters (strID)
{
var strstr = $(strID).innerHTML;
var arrEncodeChars = strstr.match(/\\u[0-9A-Z]{4,6}/g);
for (var ii = 0; ii < arrEncodeChars.length; ii++) {
var sUnescaped = eval("unescape('"+arrEncodeChars[ii]+"')");
strstr = strstr.replace(arrEncodeChars[ii], sUnescaped);
}
$(strID).innerHTML = strstr;
}
The part that takes longest is setting the innerHTML here: $(strID).innerHTML = strstr; Is there a good way to replace the characters without redoing the innerHTML of the whole page?