記在前面
在Visual Studio裏面寫MFC程序的時候,我們會遇到Unicode字符集或者是多字節字符集。多字節字符集是“傳統”的,就是以前的VS版本使用的,現在目前的Visual Studio已經不建議使用了。但還是可以用的,但是我也不建議了,因爲開發個東西還是需要面向未來的。所以,我使用的是Unicode字符集。
CString轉string
CString cs
USES_CONVERSION;
std::string str(W2A(cs));
//W是寬字符 Unicode,
//A是ANSI,
string轉CString
std::string str
USES_CONVERSION;
CString s(str.c_str());