Created
September 18, 2013 07:11
-
-
Save rednaxelafx/6605567 to your computer and use it in GitHub Desktop.
Demo of using C++11's u16string with Unicode string literal syntax
This file contains 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> // for codecvt_utf8 | |
#include <iostream> // cor cout | |
#include <locale> // for wstring_convert | |
#include <string> // for string, u16string | |
using namespace std; | |
// Compiles on LLVM 3.3 with: | |
// clang++ -std=c++11 -stdlib=libc++ xxx.cpp | |
int main() { | |
u16string s = u"alpha"; | |
wstring_convert<codecvt_utf8<char16_t>, char16_t> cv; | |
cout << cv.to_bytes(s) << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment