Created
October 25, 2016 07:05
-
-
Save remyroez/8c4d38c805141db6b35b82b041511c80 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <locale> | |
#include <codecvt> | |
int main() | |
{ | |
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter; | |
std::string u8str = u8"abcdeあいうえお🗿"; | |
std::u32string u32str = converter.from_bytes(u8str); | |
std::cout << "u8str = " << u8str << std::endl; | |
std::cout << "u8str.length = " << u8str.length() << std::endl; | |
std::cout << "u32str.length = " << u32str.length() << std::endl; | |
std::cout << "u32str = "; | |
for (auto c : u32str) | |
{ | |
std::cout << c << " "; | |
} | |
std::cout << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment