fork(1) download
  1. // http://stackoverflow.com/questions/4804298/how-to-convert-wstring-into-string/18374698#comment29617780_18374698
  2. #include <codecvt>
  3. #include <locale>
  4. #include <iostream>
  5.  
  6. int main()
  7. {
  8. std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
  9.  
  10. // utf-8 to wstring
  11. std::wstring multilingual = converter.from_bytes(u8"<abc абв αβγ 😂>");
  12. // wstring to utf-8 bytes
  13. std::cout << converter.to_bytes(multilingual) << std::endl;
  14. }
  15.  
Success #stdin #stdout 0s 15248KB
stdin
Standard input is empty
stdout
<abc абв αβγ 😂>