title: Multiplatform way to convert between std::string and std::wstring
body: <p>I am currently using the methods <code>MultiByteToWideChar</code> and <code>WideCharToMultiByte</code> of the Windows API to convert between <code>std::string</code> and <code>std::wstring</code>.</p>
  
  <p>I am 'multiplatforming' my code removing Windows dependencies, so I would like to know alternative to the methods above. Concretely, using <strong>boost</strong> will be great. Which methods may I use? Here is the code I am currently using:</p>
  
  <pre><code>const std::wstring Use::stow(const std::string&amp; str)
  {
      if (str.empty()) return L"";
      int size_needed = MultiByteToWideChar(CP_UTF8, 0, &amp;str[0], (int)str.size(), NULL, 0);
      std::wstring wstrTo( size_needed, 0 );
      MultiByteToWideChar(CP_UTF8, 0, &amp;str[0], (int)str.size(), &amp;wstrTo[0], size_needed);
      return wstrTo;
  }
  
  const std::string Use::wtos(const std::wstring&amp; wstr)
  {
      if (wstr.empty()) return "";
      int size_needed = WideCharToMultiByte(CP_UTF8, 0, &amp;wstr[0], (int)wstr.size(), NULL, 0, NULL, NULL);
      std::string strTo( size_needed, 0 );
      WideCharToMultiByte                  (CP_UTF8, 0, &amp;wstr[0], (int)wstr.size(), &amp;strTo[0], size_needed, NULL, NULL);
      return strTo;
  }
  </code></pre>