<p>I have xml where some of the element values are unicode characters. Is it possible to represent this in an ANSI encoding?</p>

<p>E.g.</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;xml&gt;
&lt;value&gt;受&lt;/value&gt;
&lt;/xml&gt;
</code></pre>

<p>to</p>

<pre><code>&lt;?xml version="1.0" encoding="Windows-1252"?&gt;
&lt;xml&gt;
&lt;value&gt;&amp;#27544;&lt;/value&gt;
&lt;/xml&gt;
</code></pre>

<p>I deserialize the XML and then attempt to serialize it using XmlTextWriter specifying the Default encoding (Default is Windows-1252). All the unicode characters end up as question marks. I'm using VS 2008,  C# 3.5</p>

[{'answer_id': 82021, 'author': 'Blair Conrad', 'author_id': 1199, 'author_profile': 'https://Stackoverflow.com/users/1199', 'pm_score': 2, 'selected': False, 'text': '<p>If I understand the question, then yes. You just need a <code>;</code> after the <code>27544</code>:</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="Windows-1252"?&gt;\n&lt;xml&gt;\n&lt;value&gt;&amp;#27544;&lt;/value&gt;\n&lt;/xml&gt;\n</code></pre>\n\n<p>Or are you wondering how to generate this XML programmatically? If so, what language/environment are you working in?</p>\n'}, {'answer_id': 82413, 'author': 'Richard Nienaber', 'author_id': 9539, 'author_profile': 'https://Stackoverflow.com/users/9539', 'pm_score': 4, 'selected': True, 'text': '<p>Okay I tested it with the following code:</p>\n\n<pre><code> string xml = "&lt;?xml version=\\"1.0\\" encoding=\\"utf-8\\"?&gt;&lt;xml&gt;&lt;value&gt;受&lt;/value&gt;&lt;/xml&gt;";\n\n XmlWriterSettings settings = new XmlWriterSettings { Encoding = Encoding.Default };\n MemoryStream ms = new MemoryStream();\n using (XmlWriter writer = XmlTextWriter.Create(ms, settings))\n      XElement.Parse(xml).WriteTo(writer);\n\n string value = Encoding.Default.GetString(ms.ToArray());\n</code></pre>\n\n<p>And it correctly escaped the unicode character thus:</p>\n\n<pre><code>&lt;?xml version="1.0" encoding="Windows-1252"?&gt;&lt;xml&gt;&lt;value&gt;&amp;#x53D7;&lt;/value&gt;&lt;/xml&gt;\n</code></pre>\n\n<p>I must be doing something wrong somewhere else. Thanks for the help.</p>\n'}]
['https://Stackoverflow.com/questions/82008', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9539/']