字符串前缀:
L :类型wchar_t 编码:Unicode
u :类型:char16_t 编码: UTF-16 (C++11)
U :类型:char32_t 编码: UTF-32(C++11)
u8 :类型char 编码: UTF-8 (C++11)
实例:
#include
usingnamespace std;
int main ()
{
wcout << L"Unicode 字符串"<< endl;//控制台字符类型为Unicode时,正常输出
wcout << u"utf-16 字符串"<< endl; //wcout 不支持的类型,输出地址
wcout << U"utf-32 字符串"<< endl; //wcout 不支持的类型,输出地址
cout << u8"utf-8 字符串"<< endl; //控制台字符类型为UTF-8时,正常输出
return0;
}
输出:
Unicode字符串
00007FF7FB864480
00007FF7FB864498
utf-8瀛楃涓?
字符串前缀与原始字符串组合:
#include
usingnamespace std;
int main ()
{
wcout << LR"(\t字\b符\r串\n)"<< endl;
return0;
}
输出:
\t字\b符\r串\n