CString类支持编码转换,使用CString完全没有必要使用MultiByteToWideChar,因为这里面已经内置的转换了。
如果你的工程是UNICODE模式,那么str=charpoint的时候,转换就已经发生。如果不是,那么只要资源中指定中文字符集,那么显示多字节的中文也是没有问题的。
CString类的源码如下:
#ifdef _UNICODE
const CString& CString::operator=(LPCSTR lpsz)
{
int nSrcLen = lpsz != NULL ? lstrlenA(lpsz) : 0;
AllocBeforeWrite(nSrcLen);
_mbstowcsz(m_pchData, lpsz, nSrcLen+1);//这个就是MultiByteToWideChar
ReleaseBuffer();
return *this;
}
#else //!_UNICODE
const CString& CString::operator=(LPCWSTR lpsz)
{
int nSrcLen = lpsz != NULL ? wcslen(lpsz) : 0;
AllocBeforeWrite(nSrcLen*2);
_wcstombsz(m_pchData, lpsz, (nSrcLen*2)+1);
ReleaseBuffer();
return *this;
}
#endif //!_UNICODE
建议你,还是检查一下MYSQL里面保存的字符串,是如何定义的字段属性,从这里查起。
解压文件出现中文乱码怎么办解决办法
典型的不兼容问题