Because the StringWriter class is derived from the TextWriter class the StringWriter have to implement the encoding property. And you created a full xml document, so the header should contains the right encoding. I can't see there any problem. But I see a problem for the reader if you write UTF-8 in the header and the document is coded in UTF-16.