int sizeTchar = sizeof(TCHAR); //uncode=2, 多字节=1
std::string str1 = "张三zhangsan";
//{ 0xe5, 0xbc, 0xa0, 0xe4, 0xb8, 0x89, 0x7a, 0x68, 0x61, 0x6e, 0x67, 0x73, 0x61, 0x6e }; --> utf-8编码
// //用notepad16进制查看,utf8 no bom和utf8 bom都是这个编码,只是bom时,文件头多了3个字节。
// str1的值,从调试内存来看,当utf8-no bom & 多字节编码 时,同上
// str1的值,从调试内存来看,当utf8-no bom & Unicode编码 时,同上
//
//
// { d5 c5 c8 fd 7a 68 61 6e 67 73 61 6e }
// str1的值,从调试内存来看,当utf8-bom & 多字节编码 时, -->GBK编码
// str1的值,从调试内存来看,当utf8-bom & Unicode编码 时 { d5 c5 c8 fd 7a 68 61 6e 67 73 61 6e }
//
CString strName1;
GetDlgItem(IDC_STATIC)->GetWindowText(strName1);
//{ d5 c5 c8 fd 7a 68 61 6e 67 73 61 6e } //多字节字符集-从控件取得 --> GBK编码(与操作系统有关)
//{ 5f20 4e09 007a 0068 0061 006e 0067 0073 0061 006e } //unicode字符集-从控件取得--> UTF-16BE编码
unsigned short buf1[128] = { 0 };
int len = strName1.GetLength();
for (int i = 0; i < len; i++)
{
TRACE("%04x \n", (unsigned short)strName1[i]);
}
TRACE("\n");
//字符编码查询:
//https://www.qqxiuzi.cn/bianma/zifuji.php
MFC字符编码规则
最新推荐文章于 2024-05-06 13:45:45 发布