C++23中可以将utf8数据直接保存在char8_t变量中
注:
1.char8_t的字面量类型通过u8定义
2.char8_t具有和unsigned char相同的符号属性、存储大小、对齐方式以及整数转换等级,但不是unsigned char。
3.由于char8_t和unsigned char不是用一种类型,所以其指针间也不同直接赋值
#include <iostream>
using namespace std;
int main()
{
auto d1 = u8'1';
cout<<is_same_v<char8_t, decltype(d1)><<endl;
cout<<is_same_v<char8_t, unsigned char><<endl;
cout<<is_same_v<char8_t*, unsigned char*><<endl;
return 0;
}
运行输出
1
0
0