你用wchar_t 声明的变量就已经是unicode。
int _tmain(int argc, _TCHAR* argv[])
{
wchar_t* test=L"我";
char buff[4];
memcpy_s(buff,sizeof(buff),test,sizeof(wchar_t)*wcslen(test));
//buff里面的内容是0x11,0x62.这个就是 我 字的unicode。我上面的操作上多余的,至少为了调试的时候好看。
return 0;
}
转换成整型输出。
char s[]="ab";
int x[3];
x[0] = 0xff & s[0];
x[1] = 0xff & s[1];
cout.setf ( ios::hex, ios::basefield );
cout << x[0] << x[1] <
x[0] = 0xffff & wch[0];
cout.setf ( ios::hex, ios::basefield );
cout << x[0] << endl;
打出16进制码