我现在用VC编基于AT命令的串口通信软件,已经实现了收发英文短信,但是中文短信的收发解决不了,各位帮帮忙,分不够可以再加!

解决方案 »

  1.   

    中文需要使用PDU模式,对GB汉字需要进行unicode编码
      

  2.   

    对应该是unicode的问题,分就不用了,可能的话把代码给大家看看。[email protected]
      

  3.   

    哈哈 其实就是UNICODE编码 你将发送的中文处理成UNICODE编码就可以了
      

  4.   

    怎么将中文处理成UNICODE编码,我不会啊。能不能提供相关的代码或教程之类的?
      

  5.   

    其实很简单的 
    使用MultiByteToWideChar(CP_ACP, 0, temp1.GetBuffer(0), -1, mid, 2);
    把你传递的字符串转换成UNICODE编码就可以了 如果还不知道 
    看下面的
    CString  EncodeChinese(CString InputStr)
    {
    int cur;
    CString tempstr,returnstr;
    CString ws,temp1;
    WCHAR  mid[2];
    ws.Format("%s", InputStr);
    cur=ws.GetLength();
    for(int i=1;i<=ws.GetLength()/2;i++)
    { temp1=ws.Mid((i-1)*2,2);
    MultiByteToWideChar(CP_ACP, 0, temp1.GetBuffer(0), -1, mid, 2);
    cur=mid[0];
    tempstr.Format("%4.4x",cur); 
    returnstr=returnstr+tempstr;
    }
    return returnstr;
    }
      

  6.   

    如果是接收后显示可以看
    CString  DecodeChinese(CString InputStr)
    {
            WCHAR Buf[300];
    char  Buf1[600];
    CString temp1;
    char temp2[20],*end;
    int pos;
    pos=InputStr.GetLength()/2;
    memset(Buf1,0x00,600);
            for(int i=0;i<InputStr.GetLength();i=i+4)
            {
    temp1=InputStr.Mid(i,4); 
    memcpy(&temp2[0],temp1.GetBuffer(0),4);
    Buf[i/4]=(int)strtol(temp2,&end,16);
            }
            Buf[InputStr.GetLength()/4]=0;
    WideCharToMultiByte(CP_ACP,0,Buf,-1,Buf1,pos,NULL,NULL);
    temp1.Format("%s", Buf1);
            return temp1;
    }
    就OK了
      

  7.   

    是不是#define _UNICODE_
    就可以了?
    CString 就认了吧
    或者_T("string")是否就行了?
      

  8.   

    to  mfkzj() :
    不对啊!我发的是“你好”,手机上收到的是4f60597d.我是用MScomm控件的这条命令发送的:
    m_ctrlComm.SetOutput(COleVariant(cEncode));cEncode的类型是CString,用于接收文本框的输入内容。
      

  9.   

    还有,接收的短信数据是这样的:
    +CMGL: 6,"REC UNREAD","+8613802146687",,"02/12/27,09:08:14+00"
    6211我如何才能将其中的6211提取出来?