c++ u8字面值字符覆盖
c++ u8 literal char override
我尝试重写字符量,以便通过使用u、u、L和u8前缀使它们char16_t、wchar_t、char32_t和char。它适用于除u8以外的所有对象。见下文:
#include <iostream>
using std::cout; using std::endl;
int main(){
cout<<"'a'----"<<'a'<<endl;
cout<<"L 'a'----"<<L'a'<<endl;
cout<<"u 'a'----"<<u'a'<<endl;
cout<<"U 'a'----"<<U'a'<<endl;
//cout<<"u8 'a'----"<<u8'a'<<endl;
return 0;
}
Consolse输出:
'a'----a
L 'a'----97
u 'a'----97
U 'a'----97
当我取消注释u8行时,我得到以下错误:
'u8' was not declared in this scope prog.cpp
你知道为什么它不工作吗?
参见http://www.cplusplus.com/doc/tutorial/constants/
u8用于字符串字面值,而u、u和L用于字符字面值。
在下一行中,您将u8前缀添加到字符字面量。cout<& lt;"与""——"& lt;
u8
字符是c++ 17的特性。确保你的编译器支持它并且你已经启用了它
相关文章:
- C++字符*缓冲区的大小
- HEX值到wchar_t字符(UTF-8)的转换
- 为什么 Serial.println(<char[]>);返回随机字符?
- 我的字符计数代码计算错误.为什么
- 字符串-C++后显示的随机字符
- 将Integer转换为4字节的unsined字符矢量(按大端字节顺序)
- 如何在C++中从字符串中分割字符
- 为什么msgrcv()将垃圾字符馈送到缓冲区
- 指向指向字符数组的指针数组的指针
- 如何用转义符替换字符串中的所有特殊字符
- 托架返回,导致COUT覆盖字符并打印出订单
- C/C++ - 生成一个随机字符串会覆盖以前的字符串(请参阅下面的代码)
- 矢量<字符*> push_back 覆盖所有条目
- 覆盖从 SHA1 返回到字符串的无符号字符*
- 覆盖标准::字符串到字符 *
- c++ u8字面值字符覆盖
- 字符串拆分为矢量<字符*>覆盖矢量元素
- 溢出字符数组每次都覆盖完全相同的字符串-为什么?
- 为什么 std::getline 会覆盖包含文件名的字符数组
- 覆盖无符号字符数组中的值时出错