//unicode:
//方法一
CString theCStr;
std::string STDStr( CW2A( theCStr.GetString() ) );
//方法二
CString m_Name;
CT2CA pszName(m_Name);
std::string m_NameStd(pszName);
//方法三
CString str = L"Test";
std::wstring ws(str);
std::string s;
s.assign(ws.begin(), ws.end());
//方法四
CString sz1 = L"abc";
std::string sz2 = CT2A(sz1.GetBuffer()); //转化为非unicode.
//非unicode:
CString sz1 = "abc";
std::string sz2 = sz1.GetBuffer();
mfc c++ CString 转换成string解决方法
最新推荐文章于 2024-07-17 13:17:18 发布