我用程序得到的是 B3 C7,我要写一个串中文的十六进制到一个exe的某一地址里面去,可是我看到他里的的汉字的代码跟我算出来的有点差别,同样一个“城”字,代码是不一样的。请问这是怎么得出来的

解决方案 »

  1.   

    MBCS:     0xC7B3
    UNICODE:  0x57CE你的是多字符集, 他用的Unicode
      

  2.   

    WCHAR * pHis = L"城";char szYours[8] = {0};
    ::WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, pHis, 1, szYours, 8, NULL, NULL);
      

  3.   

    没弄出来,小弟水平有限,麻烦再弄详细点,谢谢CString strText = "城";
    CString strResult = strtohex(strText); //我希望返回 CE 57CString strtohex(CString strOriText)
    {
        //请大家帮我填下这个函数,谢谢
    }
      

  4.   

    CString 
    StrToHex(CHAR * szOriText)
    {
    CString strResult;
    WCHAR wszTemp[2] = {0}; ::MultiByteToWideChar(CP_ACP, MB_COMPOSITE, szOriText, 2, wszTemp, 1); strResult.Format(_T("%.2X %.2X"), *(BYTE *)wszTemp, *((BYTE *)wszTemp + 1));
    return strResult;
    }