fork download
  1. #include <locale>
  2. #include <codecvt>
  3. #include <iostream>
  4. #include <cstdint>
  5.  
  6. int main() {
  7. std::wstring_convert < std::codecvt_utf8_utf16<char16_t>, char16_t> convert;
  8.  
  9. const char *s = "еёЁжикЕст";
  10. std::cout << "Input: " << s << "\n";
  11. std::u16string str = convert.from_bytes(s);
  12. for (int q=0; s[q]; ++q)
  13. std::cout << (int)s[q] << ' ';
  14. std::cout << '\n';
  15. for (int q=0; q<str.length(); ++q)
  16. std::cout << (int)str[q] << ' ';
  17. std::cout << '\n';
  18. }
  19.  
Success #stdin #stdout 0s 15248KB
stdin
Standard input is empty
stdout
Input: еёЁжикЕст
-48 -75 -47 -111 -48 -127 -48 -74 -48 -72 -48 -70 -48 -107 -47 -127 -47 -126 
1077 1105 1025 1078 1080 1082 1045 1089 1090