javascript - Getting Decoded Version of a Unicode String? -
i write variable html element that:
document.getelementbyid('mydiv').innerhtml = '<xsl:value-of select="@value"/>';
however written that:
techno a.Ş.
which should be:
techno a.Ş.
how can manually decoded version of unicode string javascript?
ps: i've realized problem occurs @ chrome not @ internet explorer.
&# , ; html parser escapes hexadecimal character. need strip off them , pass remaining '15e' value (for example):
<!doctype html> <div id="myid"> yo oyyoyoyooy &amp;amp;#xaa;suuupspuspupsu ssdosudoisduoisudoiud &amp;#xfe; </div> <script> document.addeventlistener("domcontentloaded", function(){ var nodeiterator = document.createnodeiterator( // node use root document.getelementbyid('myid'), // consider nodes text nodes (nodetype 3) nodefilter.show_text, // object containing function use acceptnode method // of nodefilter { acceptnode: function(node) { // logic determine whether accept, reject or skip node // in case, accept nodes have content // other whitespace if ( /&.*?#x[^;]+;/ig.test(node.data) ) { return nodefilter.filter_accept; } } }, false ); // show content of every non-empty text node child of root var node; while ((node = nodeiterator.nextnode())) { node.nodevalue = node.nodevalue.replace(/&.*?#x([^;]+);/ig, function(match, p1) { return string.fromcharcode(parseint(p1, 16)) }); } }); </script>
Comments
Post a Comment