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

jQuery clickable div with working mailto link inside -

java - Getting corefrences with Standard corenlp package -

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -