当前位置:网站首页>【字符集七】汉字的宽字符码和多字节码分别是多少
【字符集七】汉字的宽字符码和多字节码分别是多少
2022-06-12 08:42:00 【junxuezheng】
一、宽字符和多字节字符的本质
在windows系统设置了utf8时,char使用的是utf8字符集,而当未设置时,char使用了gbk字符集。而下面char是使用了gbk字符集。
char ch[] = “我”;
wchar_t wch[] = L"我";。
- 多字节字符就是gbk字符
- 宽字节字符是Unicode字符
- 备注:我们知道gbk是多字节字符,至于为何转换成宽字符,就是Unicode编码,可能是默认的吧。
二、汉字我的宽字符码和多字节码分别是多少
- gbk:GBK 编码、汉字编码之GBK编码(附完整码表)
- 汉字“我”:CED2是十六进制。对应的十进制就是52946.
- Unicode: https://unicode-table.com/cn/
- 汉字“我”:6211是十六进制。对应的十进制就是25105.

三、demo
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define BUFFER_SIZE 50
using namespace std;
int main()
{
setlocale(LC_ALL, "chs");
char mbyte[50];
wchar_t * wbyte =NULL;
strcpy(mbyte, "我");
size_t mlen = strlen(mbyte);
int dSize = mbstowcs(wbyte, mbyte, 0) + 1;
wbyte = new wchar_t[dSize];
wmemset(wbyte, 0, dSize);
int len = mbstowcs(wbyte, mbyte, mlen);
cout << &mbyte<<endl;
wcout << &wbyte << endl;
cout << mbyte << endl;
wcout << wbyte << endl;
return(0);
}
- 输出
00F3F984
00F3F978
我
我
备注:00F3F978为指针地址,应该查看指针指向的地址。如下图所示值为0x013107E8。地址0x013107E8中存的值为6211(如下图)
- 查看汉字“我”的gbk编码值为CED2(十六进制)、Unicode的编码值6211(十六进制)
https://blog.csdn.net/u010025662/article/details/54933530
边栏推荐
- ctfshow web 1-2
- What scheduling rules does the APS software have? What is the exception handling scheme?
- Background fixing effect
- Ankerui fire emergency lighting and evacuation indication system
- Lock mechanism in MySQL
- 【进阶指针一】字符数组&数组指针&指针数组
- Regular verification user name
- What is the difference between ERP production management and MES management system?
- UMI packaging and subcontracting, and compressing to gzip
- Webrtc adding third-party libraries
猜你喜欢

网站Colab与Kaggle

【进阶指针二】数组传参&指针传参&函数指针&函数指针数组&回调函数
![[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

Hands on deep learning -- concise implementation code of weight decay

Background location case II

Website colab and kaggle

Scope of bean

根据有效期显示距离当前还剩多少天有效期

调整svg宽高

Priority issues
随机推荐
Oracle installation details (verification)
Graphic analysis of viewbox in SVG
Convert spaces to < br / > newline labels
Audio and video related links
了结非对称密钥
QT realizes multi screen and multi-resolution adaptation
Knee joint
Specify 404 and 500 error reporting pages.
Background location case II
Priority issues
Error: what if the folder cannot be deleted when it is opened in another program
[data storage] storage of floating point data in memory
Installation of Shengxin R package
Encapsulate the amount input box component.
Webrtc adding third-party libraries
【进阶指针一】字符数组&数组指针&指针数组
Where does the driving force of MES system come from? What problems should be paid attention to in model selection?
报错:文件夹在另一个程序中打开无法删除怎么办
Configuration and principle of MSTP
Background attribute compound writing


