title: Powershell - ASCII encoding is changing special characters to question marks
body: <p>I'm using a Powershell script as follows to convert a string to XML then export to a file (done this way to keep indenting):</p>
  
  <pre><code>[xml]$xmloutput = $xml
  $sw = New-Object System.IO.StringWriter
  $writer = New-Object System.Xml.XmlTextWriter($sw)
  $writer.Formatting = [System.Xml.Formatting]::Indented
  $xmloutput.WriteContentTo($writer)
  $sw.ToString() | Set-Content -Encoding 'ASCII' $filepath
  </code></pre>
  
  <p>The destination has to be ASCII formatted due to a vendor restriction. The issue I'm seeing is ASCII just changes special characters into questions marks (example: Ö becomes ?).</p>
  
  <p>If I use UTF8 encoding the output looks totally fine. I've even tried saving to UTF8 then converting to ASCII, does the same thing (exports a question mark):</p>
  
  <pre><code>[System.Io.File]::ReadAllText($filepath) | Out-File -FilePath $filepath -Encoding ASCII
  </code></pre>
  
  <p>If I try and replace the characters in the string before the conversion to XML (using ASCII code <code>&amp;#214;</code>) it simply converts the ampersand and leaves the rest, making it useless.</p>
  
  <p>Is there any way to have Powershell correctly save those characters into the file?</p>
  
  <p>EDIT: I would like to see the special character in the outputted file, but if that is not ASCII-compliant, I'd like to see the ASCII code for it (in this example, <code>&amp;#214;</code>)</p>
  
  <p>I also don't want to see just an O, I need the actual character.</p>