title: XmlSerializer replaces non-ASCII characters with question mark '?'
body: <p>I have an XML serializer that works great for ASCII but when non-ASCII characters are encountered they are replaced with a question mark '?'.  I believe I have it configured correctly for UTF8 and am unsure why it is doing this.</p>
  
  <pre><code>XmlSerializer xmls = new XmlSerializer(typeof(T));
  using (MemoryStream ms = new MemoryStream())
  {
      XmlWriterSettings settings = new XmlWriterSettings();
      XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
      ns.Add("", "");
  
      settings.Encoding = Encoding.UTF8;
      settings.Indent = true;
      settings.NewLineChars = "\n";
      settings.NewLineHandling = NewLineHandling.None;
      settings.NewLineOnAttributes = false;
      settings.ConformanceLevel = ConformanceLevel.Document;
      settings.OmitXmlDeclaration = true;
  
      using (XmlWriter writer = XmlTextWriter.Create(ms, settings))
      {
          xmls.Serialize(writer, obj, ns);
      }
  
      string xml = Encoding.UTF8.GetString(ms.ToArray());
  
      // remove the BOM character at the beginning which screws up decoding
      if (xml.Length &gt; 0 &amp;&amp; xml[0] != '&lt;')
      {
          xml = xml.Substring(1, xml.Length - 1);
      }
  
      return xml;
  }
  </code></pre>