why does the Xdocument give me a utf16 declaration?

StringWriter advertises itself as using UTF-16. It’s easy to fix though:

public class Utf8StringWriter : StringWriter
{
    public override Encoding Encoding { get { return Encoding.UTF8; } }
}

That should be enough in your particular case. A rather more well-rounded implementation would:

  • Have constructors matching those in StringWriter
  • Allow the encoding to be specified in the constructor too

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)