如何将两个中文字节合并为一个中文字

解决方案 »

  1.   

    两个中文字节只要放到一起,在中文字符集支持下,看到的就是中文啦。(一般都有中文字符集的吧)
    比如类似0xbac4这样的,就是中文
      

  2.   

    我要把richedit里的中文保存到txt文件里,但是保存后是乱码
    void CExeManager::OnSaveAns(CString filename) 
    {
    // TODO: Add your control notification handler code here UpdateData(TRUE);
    CStdioFile file;
             CString str="";
    int nLenth;

    file.Open(filename,CFile::modeCreate|CFile::modeWrite); //m_edit.SetWindowText(filename); //获得文本的行数
    CRichEditCtrl* pEdit = (CRichEditCtrl*)GetDlgItem(IDC_EXE_ANS);
    int nCount = pEdit->GetLineCount(); char szLine[200];

    for( int i=0;i<nCount;i++ )
    {
    //第i行的长度
    nLenth = pEdit->LineLength( pEdit->LineIndex( i ) );
    pEdit->GetLine( i,szLine,nLenth ); for(int j=0;j<nLenth;j++)
    {
    char c = szLine[j]; //chinese if ( c < 0 || c > 255 )
    {
    str=str+szLine[j];
    j++;
    str=str+szLine[j];

    } //english
    else 
    {
                                  str = str + szLine[j]; 
    }
    }         str = str + "\r\n" ;

    }
    file.Seek(0,CFile::end);
    file.WriteString( str );
         file.Close();
    }
      

  3.   

    中文字不是小于0,大于255啊,底下的错了,要
    //chinese
    if ( c < 0 || c > 255 )
    {
             str=str+szLine[j];
    j++;
    str=str+szLine[j];
    }应该改为
    unsigned t;
    t=c;
    if(t>=0xA0)
    {
       str=str+szLine[j];
       j++;
       str=str+szLine[j];
    }
      

  4.   

    未发现什么错误。
    调试一下,szLine是中文么?
      

  5.   

    中文的字符是要大于0xa0小于0xff的。
      

  6.   

    保存的时候默认保存好象是2进制的
    所以看到的是乱码?
    如果转换成STRING型的 
    好象就可以看到
    学习中~~~