如何将带有中文的char指针转换给CString,在转换的过程中CString中的值变成乱码了请各位指导指导。。谢谢。。

解决方案 »

  1.   

    char* c="中文fewgewag";
    CString str;
    str.Format("%s",c);
      

  2.   

    直接用CStringA 
    用UNICODE下的CString或是CStringW 用MultiByteToWideChar转换一下
      

  3.   

    如果定义了UNICODE
    就需要对于char字串进行编码转换:MultiByteToWideChar
    然后将转换后的UNICODE字串赋值给 CSting
      

  4.   

    char buf[] = "Hello,你好!world";
    CString strText(buf);
    AfxMessageBox(strText);
      

  5.   

    .format("%s",)
    或者直接 CSTRING =.char*
      

  6.   

    如果编译器设置了UNICODE,使用MultiByteToWideChar转成UNICODE,然后直接CString str(unicode);
      

  7.   

    char buf[]="hello world!";
    Cstring str;
    str = buf;
    ===========================
    char tt[100];
    strcpy(tt, str);