当前位置:网站首页>[character set 8] char8_ t、char16_ t、char32_ t、wchar、char
[character set 8] char8_ t、char16_ t、char32_ t、wchar、char
2022-06-12 08:52:00 【junxuezheng】
One 、vs How the compiler supports C++20 standard
Two 、 brief introduction
char :
c++ Keywords in , Occupy 1 Bytes .char16_t、char32_t
https://en.cppreference.com/w/c/string/multibyte/char16_tchar8_t:c++20 New keywords added to the standard .
https://open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0482r6.html
3、 ... and 、demo
#include <iostream>
using namespace std;
int main()
{
//char* loc = setlocale(LC_ALL,".65001");
char ch[] = " I ";
char8_t ch8[] = u8" I ";
wchar_t wch[] = L" I ";
char16_t ch16[] = u" I ";
char32_t ch32[] = U" I ";
cout << &ch<<endl;
cout << &ch8 << endl;
cout << &wch << endl;
cout << &ch16 << endl;
cout << &ch32 << endl<<endl;
/*cout << ch << endl; wcout << wch << endl;*/
printf("ch:%#x", ch[0]); printf("%#x", ch[1]); printf("%#x", ch[2]); printf("%#x", ch[3]);
printf("\n");
printf("ch8:%#x", ch[0]); printf("%#x", ch8[1]); printf("%#x", ch8[2]); printf("%#x", ch8[3]);
printf("\n");
printf("wch:%#x", wch[0]);
printf("\n");
printf("ch16:%#x", ch16[0]);
printf("\n");
printf("ch32:%#x", ch32[0]);
printf("\n");
}
Output :
00B7F83C
00B7F830
00B7F824
00B7F818
00B7F808
ch:0xffffffe60xffffff880xffffff910
ch8:0xffffffe60x880x910
wch:0x6211
ch16:0x6211
ch32:0x6211
utf-8 Is one Chinese character three bytes long ?
Four 、 analysis
- char and char8_t The number stored in is :e6 88 91. Represents my character code of Chinese characters , Three bytes , Refer to Character set vs Character encoding . Install the calculation method in the article , After conversion, it is also equal to 62 11.
- wchar_t、char16_t、char_32t The number stored in is :62 11. among 6211 by Unicode Chinese characters ” I " Character encoding of ; See What are the wide character codes and multi byte codes of Chinese characters
5、 ... and 、c++20 standard :char8_t Can't output
Recap
char8_t can not hold a full range of utf-8 glyphs. utf-8 glyphs can be up to 4 bytes. char8_t holds up to 1 byte.
char8_t stream out is expressly forbidden in C++20
for utf-8 compatibility while in VStudio use char and the /utf-8 switch
in case you really want C++20 way of transforming to/from char8_t, you need to use … AFAIK not yet fully implemented in any of the 3, as required by the standard
边栏推荐
- 分库分表会带来读扩散问题?怎么解决?
- Oracle installation details (verification)
- Webrtc series - mobile terminal hardware coding supports simulcast
- API处理Android安全距离
- 第八章-数据处理的两个基本问题
- Dynamic segment tree leetcode six hundred and ninety-nine
- 第三章 寄存器 (内存访问)
- Display the remaining valid days according to the valid period
- js实现页面加载后再刷新一次
- 【数据存储】浮点型数据在内存中的存储
猜你喜欢

报错:清除网站内搜索框中的历史记录?

Engineers learn music theory (II) scale and tendency

xshell启动遇到“由于找不到mfc110.dll,无法继续执行代码的解决方法”
![[advanced pointer 2] array parameter transfer & pointer parameter transfer & function pointer & function pointer array & callback function](/img/90/447d601a8c338cdd5a6674a2dc59ae.png)
[advanced pointer 2] array parameter transfer & pointer parameter transfer & function pointer & function pointer array & callback function

About weights exercise

Background location case II

【新规划】

Implementing architecture caching in MySQL under redis server environment
![[advanced pointer III] implement C language quick sorting function qsort & callback function](/img/f0/3729db83ba3eb15c7df0958858ece9.png)
[advanced pointer III] implement C language quick sorting function qsort & callback function

Hypergeometric cumulative distribution test overlap
随机推荐
动态线段树leetcode.699
正则校验用户名
[essence] explain in detail the memory management mechanism in QT
[dynamic memory management] malloc & calloc and realloc and written test questions and flexible array
Background position position NOUN
Centso8 installing mysql8.0 (Part 2)
Set up redis sentinel cluster (instance):
Close asymmetric key
Error: clear the history in the search box in the website?
About weights exercise
Error: what if the folder cannot be deleted when it is opened in another program
Knee joint
FDA reviewers say Moderna covid vaccine is safe and effective for children under 5 years of age
torch. logical_ And() method
Analysis of 43 cases of MATLAB neural network: Chapter 7 regression of RBF Network -- Realization of nonlinear function regression
调整svg宽高
【 pointeur avancé Ⅲ】 mise en œuvre de la fonction de tri rapide qsort& fonction de rappel en langage C
2022.6.9-----leetcode. four hundred and ninety-seven
Engineers learn music theory (I) try to understand music
What is the beauty of MES equipment management for enterprises?
