Hello,
I have this code to create an ATOM feed
Dim xmlResult As New StringBuilder
Dim settings As New XmlWriterSettings
Dim atomWriter As XmlWriter = XmlWriter.Create(xmlResult, settings)
Dim atomFormatter As Atom10FeedFormatter = New Atom10FeedFormatter(feed)
atomFormatter.WriteTo(atomWriter)
atomWriter.Close()
It returns XML that starts like this:
<?xml version="1.0" encoding="utf-16"?><feed xmlns="http://www.w3.org/2005/Atom">
No matter what I try I can't get it to return utf-8 instead of utf-16. When it is utf-16 it fails to work with IE8 but utf-8 works OK. How do I know it works OK I hear you ask if I can't get it to return utf-8, well I end up using this line of code to return the feed to the browser:
Response.Write(Replace(xmlResult.ToString, "utf-16", "utf-8"))
Which is surely the worst hack you've seen today, if it isn't I feel sorry for you!
So this is what I have tried to get UTF-8:
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.Charset = "UTF-8"
settings.Encoding = System.Text.Encoding.UTF8
The settings line is what I thought would work but isn't for me. My understanding is that the XML Writer is the part that is adding the XML declaration but as the settings.Encoding doesn't work I'm stumped. Please help!
Thanks