title: What most correct way to set the encoding in C++?
body: <p>How it is best of all to set the encoding in C++?</p>
  
  <p>I got used to working with Unicode (and <code>wchar_t</code>, <code>wstring</code>, <code>wcin</code>, <code>wcout</code> and L" ... "). I also save source in UTF-8.</p>
  
  <p>At the moment I use MinGW (Windows 7) and run my program in Windows console (cmd.exe), but sometimes I can use gcc on GNU\Linux and run promgram in Linux console with UTF-8 encoding.</p>
  
  <p>At all times I want to compile my source on Windows and on Linux and I want that all Unicode symbols were correctly inputed and outputed.</p>
  
  <p>When I faced the next problem with encodings, I googled. Also I found the most different councils: <code>setlocale(LC_ALL, "")</code> and <code>setlocale(LC_ALL, "xx_XX.UTF-8")</code>, <code>std::setlocale(LC_ALL, "")</code> and <code>std::setlocale(LC_ALL, "xx_XX.UTF-8")</code> from <code>&lt;clocale&gt;</code>,</p>
  
  <p><code>SetConsoleCP()</code> and <code>SetConsoleOutputCP()</code> from <code>&lt;windows.h&gt;</code> and many, many others.</p>
  
  <p>At last I was bothered by this shamanism and I want to ask you: how it is correct to establish the encoding?</p>