Created
June 11, 2019 02:08
-
-
Save islishude/08c10e3e52ec6f649ce3925a81f6345e to your computer and use it in GitHub Desktop.
utf8 iterator for cpp
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 <codecvt> | |
#include <locale> | |
#include <iostream> | |
#include <string> | |
int main() | |
{ | |
std::u32string input = U"这是中文"; | |
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter; | |
for (char32_t c : input) | |
{ | |
std::cout << converter.to_bytes(c) << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment