title: How to change encoding in TextWriter object?
body: <p>I have xml which I send by API in another resurse. I create it by XDocument:</p>
  
  <pre><code>XDocument xDoc = new XDocument(
      new XDeclaration("1.0", "utf-8", "yes"),
      new XElement("Entity",new XAttribute("Type", "attribute1"),
          new XElement("Fields",...
  </code></pre>
  
  <p>When I put it in the request it has sent without declaration. So I do next:</p>
  
  <pre><code>StringBuilder builder = new StringBuilder();
  TextWriter writer = new StringWriter(builder);
  
  using (writer)
  {
      xDoc.Save(writer);
  }
  </code></pre>
  
  <p>But now TextWriter change encoding in xml to utf-16. I need to change it again on utf-8.</p>