char *szBuf="專案管理導出範本";
unsigned char ch1=szBuf[1];
unsigned char ch2=szBuf[0];CString str;
str.Format("ch1: %d", ch1);//szbuf[1]=163
AfxMessageBox(str);//return; str.Format("ch2: %d", ch2);//szbuf[0]=140, 低字节。
AfxMessageBox(str);//return;可见输出分别为 163和140,这不在big5编码范围之内,却在GBK之内。说明他是以GBK读入的。那么我该怎么让他读入时以big5的方式读入呢?

解决方案 »

  1.   

    你想要BIG5吗,那你只要用big5码的输入法来输入该字就可以读到big5码了
      

  2.   

    CString Convert(CString str, int sourceCodepage, int targetCodepage) 

    int len=str.GetLength(); int unicodeLen=MultiByteToWideChar(sourceCodepage,0,str,-1,NULL,0); wchar_t * pUnicode; 
    pUnicode=new wchar_t[unicodeLen+1]; memset(pUnicode,0,(unicodeLen+1)*sizeof(wchar_t)); 
    MultiByteToWideChar(sourceCodepage,0,str,-1,(LPWSTR)pUnicode,unicodeLen); BYTE * pTargetData; 
    int targetLen=WideCharToMultiByte(targetCodepage,0,(LPWSTR)pUnicode,-1,(char *)pTargetData,0,NULL,NULL); pTargetData=new BYTE[targetLen+1]; 
    memset(pTargetData,0,targetLen+1); WideCharToMultiByte(targetCodepage,0,(LPWSTR)pUnicode,-1,(char *)pTargetData,targetLen,NULL,NULL); CString rt; 
    rt.Format("%s",pTargetData); delete pUnicode; 
    delete pTargetData; 
    return rt; } 
    用法 
    Convert(str,936,950); 
      

  3.   

    to ToperRay(绿皮狼):
    设置区域要重启电脑,太麻烦。to CathySun118(斯年) :
    设成unicode也是不行的。只有goodboyws(深夜不眠者(VCMVP)) 的方法是管用的,谢谢啦。