Problems with DOM Parsing/Serialization and character encodings?
[email protected] (Matthew Wilson)
| Newsgroups | gmane.comp.mozilla.devel.xml |
|---|---|
| Organization | http://groups.google.com |
| Message-ID | <[email protected]> |
Are there any issues using Mozilla DOM Parsing or Serialization and character encodings? For example, using Cyrillic characters via numeric entity references (I hope I have that term correct) in an ISO-8859-1 document: var text = "Выбрать"; var xml = "<?xml version='1.0' encoding='ISO-8859-1'?>\n<test>" + text + "</test>"; window.alert (xml); This outputs the string exactly as you would expect, with the numeric characters intact. If I then make an XMLDocument out of the text, and print the value of the text node: var originalDoc = new DOMParser().parseFromString(xml, "text/xml"); window.alert (originalDoc.documentElement.childNodes[0].data); then I see the actual Cyrillic characters. I'll paste them in here, but I don't know how successful that will be: Выбрать I think that's still correct. Then if I serialize it back to a string and print the result, the numeric character entity references are gone, I still have the Cyrillic characters, and the XML declaration still has an encoding of ISO-8859-1: var serializedDoc = new XMLSerializer().serializeToString (originalDoc); window.alert (serializedDoc); <?xml version="1.0" encoding="ISO-8859-1"?> <test>Выбрать</test> That looks wrong to me. Any opinions? Matthew Wilsno