title: Unicode chars in console through C++
body: <p>Windows 8 x64;
  Visual Studio 2012;</p>
  
  <p>I learn C++ by book. On this forum I found <a href="https://stackoverflow.com/search?q=Unicode%20console%20C%2b%2b&amp;submit=search">many themes</a> about read\write Unicode strings through C++. But this themes not marked as solved(???). Is it really big problem in C++? I have tried different variants - they not working to me:</p>
  
  <pre><code>#include&lt;iostream&gt;
  #include&lt;Windows.h&gt;
  #include &lt;io.h&gt;
  #include &lt;fcntl.h&gt;
  using namespace std;
  
  int main() {
      // variant 1:
      wcout &lt;&lt; L"Hello World!" &lt;&lt; endl; // displayed
      wcout &lt;&lt; L"Привет Мир!" &lt;&lt; endl;// not displayed
  
      //**********************************************
  
      // variant 2:
      SetConsoleOutputCP(CP_UTF8);
      wchar_t s[] = L"Hello World (2)!";
      int bufferSize = WideCharToMultiByte(CP_UTF8, 0, 
          s, -1, NULL, 0, NULL, NULL);
      char* m = new char[bufferSize]; 
      WideCharToMultiByte(CP_UTF8, 0, s, -1, m, 
          bufferSize, NULL, NULL);
  
      wprintf(L"%S", m); // valid output
      wcout &lt;&lt; endl;
      printf("%s", m); // valid output
      wcout &lt;&lt; endl;
  
      wchar_t s2[] = L"Привет мир (2)!";
      int bufferSize2 = WideCharToMultiByte(CP_UTF8, 0, 
          s2, -1, NULL, 0, NULL, NULL);
      char* m2 = new char[bufferSize2]; 
      WideCharToMultiByte(CP_UTF8, 0, s2, -1, m2, 
          bufferSize2, NULL, NULL);
  
      wprintf(L"%S", m2); // invalid output
      wcout &lt;&lt; endl;
      printf("%s", m2); // invalid output
      wcout &lt;&lt; endl;
      //**********************************************
  
      // variant 3 (not working):
      _setmode(_fileno(stdout), _O_U16TEXT);
      wcout &lt;&lt; L"Testing unicode -- English -- Ελληνικά"
          &lt;&lt; "-- Español." &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>But it works for English chars only... 
  Screen:</p>
  
  <p><img src="https://i.stack.imgur.com/amvoA.png" alt="enter image description here"></p>
  
  <p>How can I solve it problem through C++?</p>