encoding of XML DOM document created in memory

Martin Honnen <[email protected]> Thu, 01 May 2008 18:04:56 +0200
Newsgroups gmane.comp.mozilla.devel.xml
Organization Liberty Development
Message-ID <[email protected]>
In 
http://groups.google.com/group/mozilla.dev.ajax/browse_thread/thread/e0e6ccdf8dcaac95/a8544ca54082f1e1?lnk=st&q=#a8544ca54082f1e1 
someone complains that Firefox 3.0 encodes an XML DOM document created 
with document.implementation.createDocument() and sent with the send() 
method of XMLHttpRequest as ISO-8859-1. I can confirm that. The 
documentation http://developer.mozilla.org/en/docs/XMLHttpRequest says 
that Firefox prior to 3.0 always used UTF-8 while Firefox 3.0 uses 
doc.characterSet to encode an XML DOM document passed to the send 
method. The problem however is that Firefox in both 2.0 and 3.0 sets the 
characterSet property of a document created with 
document.implementation.createDocument() to ISO-8859-1 and you can't 
change that with script as far as I can see. That means that now with 
Firefox 3.0 all such documents are ISO-8859-1 encoded which is a problem 
to people who want to send UTF-8 encoded documents and process them on 
the server. Also using ISO-8859-1 causes a bloat of the sent data as any 
characters outside of that encoding are then sent as numerical character 
references.
Does anyone know why Firefox sets characterSet to ISO-8859-1 for XML DOM 
documents created in memory with createDocument? Is it possible to 
change that to UTF-8?


-- 

	Martin Honnen
	http://JavaScript.FAQTs.com/