title: Windows encoding changed when redirecting output
body: <p>Hi I have the following python file 'test.py':</p>
  
  <pre><code>import sys
  print(sys.stdout.encoding)
  sys.stdout.reconfigure(encoding='utf-8') 
  print(sys.stdout.encoding)
  </code></pre>
  
  <p>when I run </p>
  
  <pre><code>py test.py
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>utf-8
  utf-8
  </code></pre>
  
  <p>but when I run </p>
  
  <pre><code>py test.py &gt; test.txt
  </code></pre>
  
  <p>or</p>
  
  <pre><code>py test.py | Out-File -FilePath test.txt -Encoding ASCII
  </code></pre>
  
  <p>I get from test.txt:</p>
  
  <pre><code>cp1252
  utf-8
  </code></pre>
  
  <hr>
  
  <p>Update:
  when I run following python code:</p>
  
  <pre><code>import sys, locale
  print(sys.getdefaultencoding())
  print(locale.getpreferredencoding())
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>utf-8
  cp1252
  </code></pre>
  
  <hr>
  
  <p>Question:<br>
  May I know why this happen and what should I do so that the default encoding is utf-8 when redirecting?<br>
  Thanks</p>