I am testing a web service that returns an XML doc as a string. I went
through troubles when developing it whereby the saved output of the
service would not display in Internet Explorer due to encoding confusion.
I finally settled on setting responseEncoding in my web.config file to
"utf-16" and saving the output of the service encoded as "Unicode"
(using Textpad where the options are "utf-8" and "Unicode") and
everything was fine. This seemed to make sense since the encoding of a
StringWriter that writes the string is "Unicode".
After deploying the service to another machine, I.E. will no longer open
the output. If I manually change the encoding attribute of the XML doc
to "utf-8" and save it encoded that way, I.E. likes it. However, the
StringWriter encoding property is read-only so I can't change it from
"Unicode", and changing my responseEncoding Web.Config setting has no
effect.
Brad Wood - 17 Mar 2005 02:21 GMT
Hit the wrong keys and sent last post before I was done.
Anyway, my question is: if the StringWriter's encoding is "Unicode", and
I'm saving the output encoded as "Unicode" and the first line of the XML
doc is:
<?xml version="1.0" encoding="utf-16"?>
Why does I.E. think the encoding is messed up?