部分代码
char buf[255];
m_recv.Receive(buf,255);    //接收消息    
CString msg;
msg.Format("%s", buf); 
将接收到的消息倒置,可是倒置后中文为乱码,高手帮帮忙啊!!

解决方案 »

  1.   

    ASCII字符倒置单位为1字节,中文倒置单为2字节.如果你是半角中英混排的,就不好处理了.
      

  2.   

    用MultiByteToWideChar 把buf变成Unicode字符串处理
      

  3.   

    temp = strlen(cache_file) + 1;
    wLen = MultiByteToWideChar(CP_ACP, 0, cache_file, temp, NULL, 0);cache_fileW = new WCHAR[wLen];
    MultiByteToWideChar(CP_ACP, 0, cache_file, temp, cache_fileW, wLen);