How to specify the encoding of an XML document using Javascript -


hello trying create document using javascript , there's problem encoding of document, because reject non-ascii characters, string im passing "verificación" replaced "�", how can fixed that.

this code:

function createdoc(string){     if (window.domparser)       {         parser = new domparser();           doc = parser.parsefromstring('<?xml version="1.0" encoding="utf-8"?>'+string, "text/xml");       }     else // internet explorer       {         doc = new activexobject("microsoft.xmldom");         doc.async = "false";         doc.loadxml('<?xml version="1.0" encoding="utf-8"?>'+string);       }      return doc } 

thanks in advance.

javascript strings utf-16-encoded. try specifying that.

where string come from? string correct before parsing it?

also, when being displayed? encoding expected there?


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -