title: Is it possible to print UTF-8 string with Boost and STL in windows console?
body: <p>I'm trying to output UTF-8 encoded string with cout with no success. I'd like to use Boost.Locale in my program. I've found some info regarding windows console specific. For example, this article <a href="http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/running_examples_under_windows.html" rel="nofollow">http://www.boost.org/doc/libs/1_60_0/libs/locale/doc/html/running_examples_under_windows.html</a> says that I should set output console code page to 65001 and save all my sources in UTF-8 encoding with BOM. So, here is my simple example:</p>
  
  <pre><code>#include &lt;windows.h&gt;
  #include &lt;boost/locale.hpp&gt;
  
  using namespace std;
  using namespace boost::locale;
  
  int wmain(int argc, const wchar_t* argv[])
  {
      //system("chcp 65001 &gt; nul"); // It's the same as SetConsoleOutputCP(CP_UTF8)
      SetConsoleOutputCP(CP_UTF8);
  
      locale::global(generator().generate(""));
  
      static const char* utf8_string = u8"♣☻▼►♀♂☼";
  
      cout &lt;&lt; "cout: " &lt;&lt; utf8_string &lt;&lt; endl;
      printf("printf: %s\n", utf8_string);
  
      return 0;
  }
  </code></pre>
  
  <p>I compile it with Visual Studio 2015 and it produces the following output in console:</p>
  
  <pre><code>cout: ���������������������
  printf: ♣☻▼►♀♂☼
  </code></pre>
  
  <p>Why does printf do it well and cout don't? Can locale generator of Boost help with it? Or should I use somethong other to print UTF-8 text in console in stream mode (cout-like approach)?</p>