你如何在C++中使用unicode?林意识到wchar_t和wchar_t*,但我想知道如何可以只使用Unicode值赋值,类似于一个角色可以通过等同的变量的ASCII值分配方式:
char a = 92;
Run Code Online (Sandbox Code Playgroud)
我正在使用MinGW编译器,如果它有所作为.
它可以很简单:
wchar_t a=L'a';
wchar_t hello_world[]=L"Hello World";
// Or if you really want it to be (old school) C++ and not C
std::wstring s(L"Hello World");
// Or if you want to (be bleeding edge and) use C++11
std::u16string s16(u"Hello World");
std::u32string s32(U"Hello World for the ??? time");
Run Code Online (Sandbox Code Playgroud)
完全相同的方式:
\n\nwchar_t a = 97;\nwchar_t xi = 0x03be; // \xce\xbe\nRun Code Online (Sandbox Code Playgroud)\n