XmlException when setting encoding in XmlStreamWriter.writestartDocument()
Last updated 2020-09-25 ·Reference W-1478733 ·Reported By 16 users
No Fix
Summary
Setting a value for the encoding in XmlStreamWriter.writeStartDocument(string,string) may result in the following error:
System.XmlException: Underlying stream encoding 'UTF-8' and input paramter for writeStartDocument() method 'ISO-8859-1' do not match.
Repro
Run the following code in a Developer Console:
XmlStreamWriter xsw = new XmlStreamWriter();
xsw.writeStartDocument('ISO-8859-1', '1.0');
Workaround
Currently no workaround exists. XmlStreamWriter is instantiated using the default encoding.
Is it Fixed?
Any unreleased services, features, statuses, or dates referenced in this or other public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make their purchase decisions based upon features that are currently available.