title: Display UTF-8 output on Windows command prompt
body: <p>On Windows, the output of PHP command-line scripts is interpreted according to currently configured code page and console font. Here in Western Europe this often defaults to <a href="http://en.wikipedia.org/wiki/Code_page_850" rel="nofollow noreferrer">850</a> and <em>bitmap</em>. That means that a script written as UTF-8 (the de-facto standard since PHP/5.4):</p>
  
  <pre><code>&lt;?php
  echo 'Café: 1,25 €' . PHP_EOL;
  </code></pre>
  
  <p>... will typically look this way:</p>
  
  <pre><code>C:\tmp&gt;php test.php
  Caf├®: 1,25 Ôé¼
  </code></pre>
  
  <p>The <a href="https://stackoverflow.com/questions/388490/unicode-characters-in-windows-command-line-how">usual workaround</a> is use a <code>*.bat</code> wrapper:</p>
  
  <pre><code>@echo off
  chcp 65001 &gt; NUL
  php test.php
  </code></pre>
  
  <p>It doesn't fix the font issue but it's normally good enough.</p>
  
  <p>My double question:</p>
  
  <ol>
  <li><p>Is it possible to set the code page from within PHP so we can omit the wrapper? (Using program execution functions to run <code>chcp</code> does not work because it happens in a different process.)</p></li>
  <li><p>Is this a limitation of the console libraries used by PHP? (Node.js scripts always displays correct output from UTF-8 sources no matter the local code page, font aside.)</p></li>
  </ol>