Encoding using XmlTextWriter
.NET (Core and Framework)
1
Posts
1
Posters
0
Views
1
Watching
-
Hi, When trying to write my xml data to a string using StringWriter and XmlTextWriter it writes to the string and sets the encoding to UTF-16. How do I control the encoding when writing to a string (when writing to a file with Filestream I can control the encoding through the XmlTextWriter constructor)? Here is a codesnippet of my code: System.IO.StringWriter sw = new System.IO.StringWriter(); XmlTextWriter writer = new XmlTextWriter(sw); writer.Formatting = Formatting.Indented; writer.WriteStartDocument(); .... writer.WriteEndDocument(); MessageBox.Show(sw.ToString()); Johannes