Unicode字符集下,CString 转换为char类型

来源:互联网 发布:kafka golang group 编辑:程序博客网 时间:2024/05/16 12:21

//CString 转换为char类型,Unicode字符集下

    UINT num = WideCharToMultiByte(CP_ACP,0,m_SendData,m_SendData.GetLength(),NULL,0,NULL,NULL);                                                 //为多字节字符数组申请空间,数组大小为按字节计算的宽字节字节大小    char * c = new char[num];                   //以字节为单位    WideCharToMultiByte(CP_ACP,0,m_SendData,m_SendData.GetLength(),c,num,NULL,NULL);//宽字节编码转换成多字节编码         

其中,m_SendData为待转换的CString类型,c为转换后的字符串,num为字符串长度。

0 0
原创粉丝点击