title: Unicode output in Python's stdout when running from cmd.exe
body: <p>I am running Windows 7 and its console has been configured to use Consolas font, which gives me a possibility of Unicode output. The ability to read Unicode in console has been proved by me many times for programs such as Far Manager: both Cyrillics and German äöü letters can be read on the same console in the same string without encoding switching.</p>
  
  <p>Now about Python.</p>
  
  <p>I am trying very hard, but can't see Unicode in it's output.
  By default <code>print(sys.stdout.encoding)</code> prints <code>cp866</code> and stdout is unable to output any characters except ASCII and Cyrillics.</p>
  
  <p>It gives me following results:</p>
  
  <p><code>print("Ля-ля äöüÄÖÜß")</code></p>
  
  <p><code>UnicodeEncodeError: 'charmap' codec can't encode characters in position 6-12: character maps to &lt;undefined&gt;</code></p>
  
  <p><code>print("Ля-ля äöüÄÖÜß".encode("utf-8"))</code></p>
  
  <p><code>b'\xd0\x9b\xd1\x8f-\xd0\xbb\xd1\x8f \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f'</code></p>
  
  <p>Ok, I've set the <code>PYTHONIOENCODING</code> environment variable in batch file:</p>
  
  <p><code>SET PYTHONIOENCODING=UTF-8</code></p>
  
  <p>and got:</p>
  
  <pre><code>print(sys.stdout.encoding)
  UTF-8
  
  print("Ля-ля äöüÄÖÜß")
  ╨Ы╤П-╨╗╤П ├д├╢├╝├Д├Ц├Ь├Я
  
  print("Ля-ля äöüÄÖÜß".encode("utf-8"))`
  b'\xd0\x9b\xd1\x8f-\xd0\xbb\xd1\x8f \xc3\xa4\xc3\xb6\xc3\xbc\xc3\x84\xc3\x96\xc3\x9c\xc3\x9f'
  </code></pre>
  
  <p>What to do?</p>