title: PHP SimpleXML asXML writes ANSI encoded file
body: <p>I am trying to write some content into an XML file, yet I do have problems with special characters.</p>
  
  <p>The content I'd like to write is submitted to the script via <code>$_GET</code>, so I assume it is properly decoded into UTF-8 content.</p>
  
  <pre><code>$write = $_GET['content'];
  </code></pre>
  
  <p>will be fed like:</p>
  
  <pre><code>file.php?content=s%F6per
  </code></pre>
  
  <p>In the PHP I do the following:</p>
  
  <pre><code>$xml = simplexml_load_file('file.xml');
  $newentry = $xml -&gt; addChild('element',$write);
  $xml -&gt; asXML($xml_filename);
  </code></pre>
  
  <p>The XML file that is opened is UTF-8 encoded. When I write content without any of those "problem characters" the asXML will save the file in UTF-8 again. As soon as I insert special characters it gets saved in ANSI encoding, messing up the file as I won't be able to open it (the script will complain about improper encoding) anymore.</p>
  
  <p>What am I missing? Reading the manual gives me the impression that I should be doing everything ok (i.e. not messing with the <code>$_GET['content']</code>), so I unfortunately have no clue.</p>
  
  <p>Thanks so much!</p>