title: Properly print utf8 characters in windows console
body: <p>This is the way I try to do it:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;windows.h&gt;
  using namespace std;
  
  int main() {
    SetConsoleOutputCP(CP_UTF8);
     //german chars won't appear
    char const* text = "aäbcdefghijklmnoöpqrsßtuüvwxyz";
    int len = MultiByteToWideChar(CP_UTF8, 0, text, -1, 0, 0);
    wchar_t *unicode_text = new wchar_t[len];
    MultiByteToWideChar(CP_UTF8, 0, text, -1, unicode_text, len);
    wprintf(L"%s", unicode_text);
  }
  </code></pre>
  
  <p>And the effect is that only us ascii chars are displayed. No errors are shown. The source file is encoded in utf8.</p>
  
  <p>So, what I'm doing wrong here ?</p>
  
  <p>to WouterH:</p>
  
  <pre><code>int main() {
    SetConsoleOutputCP(CP_UTF8);
    const wchar_t *unicode_text = L"aäbcdefghijklmnoöpqrsßtuüvwxyz";
    wprintf(L"%s", unicode_text);
  }
  </code></pre>
  
  <ul>
  <li>this also doesn't work. Effect is just the same. My font is of course Lucida Console.</li>
  </ul>
  
  <p>third take:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #define _WIN32_WINNT 0x05010300
  #include &lt;windows.h&gt;
  #define _O_U16TEXT  0x20000
  #include &lt;fcntl.h&gt;
  
  using namespace std;
  
  int main() {
      _setmode(_fileno(stdout), _O_U16TEXT);
      const wchar_t *u_text = L"aäbcdefghijklmnoöpqrsßtuüvwxyz";
      wprintf(L"%s", u_text);
  }
  </code></pre>
  
  <p>ok, something begins to work, but the output is: <code>ańbcdefghijklmno÷pqrs▀tuŘvwxyz</code>.</p>