C 中的L前缀到底是什么
What exactly is the L prefix in C++?
我明白它的作用:将字符串字母指定为 const wchar_t *
(宽字符串)而不是 const char *
(纯旧字符),但是如何实际定义?
它是某种宏吗?是海湾合作委员会编译器的运营商吗?什么是 it?
字面前缀是核心语言的一部分,就像后缀:
'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
请注意, wchar_t
具有 nothing 与unicode一起做。这是我关于该主题的延长咆哮。
它称为编码前缀:
2.14.5字符串文字[lex.string]
string-literal
:
|encoding-prefix
opt
"s-char-sequenceopt
"
|encoding-prefix
opt
rraw-string
encoding-prefix
:
|u8
|u
|U
|L
标记一个宽字的字面文字:
11)以
L
(例如L"asdf"
)开头的字符串文字是一个宽 字符串字面量。一个宽字的字面字面具有"n
const wchar_t
的数组"类型,其中N是字符串的大小,如下所示;它有 静态存储持续时间,并用给定的字符初始化。
l这里的含义是宽字符: wchar_t
。带有L的字符串以16位而不是8位编码,以一个示例:
"A" = 41
L"A" = 00 41
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- C++避免重复声明的语法是什么
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 实现无开销push_back的最佳方法是什么
- C++从另一个类访问公共静态向量的正确方法是什么
- "throw expression code" 1e7 >返回 d 是什么?投掷标准::overflow_error( "too big" ) : d;意味 着?
- C++中名称篡改的目的是什么
- 在 c++ 中拥有一组结构的正确方法是什么?
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 是什么阻止DOMTimerCoordinator::NextID进入无休止的循环
- 派生类销毁的最佳实践是什么
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 在 WScript.CreateObject 中使用前缀的目的是什么?
- 在QT资源系统中,前缀比文件系统路径的优势是什么?
- 在一行C 中,该代码后缀和前缀的输出的逻辑是什么
- C 中的L前缀到底是什么
- 在Windows中获取安装前缀的最佳方法是什么
- 什么是 C# @ 符号前缀字符串的C++等效项
- "cxa"前缀在"__cxa_demangle"中是什么意思?
- 在源文件中指定include前缀与在编译器的搜索路径参数中指定include前缀的优缺点是什么