use*_*369 45 c++ string widestring
我理解它的作用:将字符串文字指定为const wchar_t *(宽字符串)而不是const char *(普通旧字符),但它是如何实际定义的?
它是某种宏吗?它是GCC编译器的运算符吗?这是什么?
Ker*_* SB 70
文字前缀是核心语言的一部分,很像后缀:
'a' // type: char
L'a' // type: wchar_t
"a" // type: char[2]
L"a" // type: wchar_t[2]
U"a" // type: char32_t[2]
1 // type: int
1U // type: unsigned int
0.5 // type: double
0.5f // type: float
0.5L // type: long double
Run Code Online (Sandbox Code Playgroud)
请注意,wchar_t有没有做使用Unicode.这是我对该主题的一个延伸的咆哮.
Luc*_*ore 18
它被称为编码前缀:
string-literal:
|encoding-prefixopt"s-char-sequenceopt"
|encoding-prefixoptRraw-string
encoding-prefix:
|u8
|u
|U
|L
并标记一个宽字符串文字:
11)以
L(例如)L"asdf"宽字符串文字开头的字符串文字.宽字符串文字的类型为"array ofnconst wchar_t",其中n是字符串的大小,如下所示; 它具有静态存储持续时间,并使用给定的字符进行初始化.
这里L的意思是广泛的:wchar_t.带L的字符串以16位而不是8位编码,举个例子:
"A" = 41
L"A" = 00 41
Run Code Online (Sandbox Code Playgroud)