std::string CString2string(CString input)
{
#ifdef UNICODE
int len = WideCharToMultiByte(CP_ACP, 0, LPCWSTR(input), -1, NULL, 0, NULL, NULL);
char *str = new char[len];
memset(str, 0, len);
WideCharToMultiByte(CP_ACP, 0, LPCWSTR(input), -1, str, len, NULL, NULL);
std::string output(str);
delete[] str;
return output;
#else
return std::string((LPCSTR)input);
#endif // !UNICODE
}
CString string2CString(std::string input)
{
#ifdef UNICODE
int len = MultiByteToWideChar(CP_ACP, 0, input.c_str(), -1, NULL, 0);
wchar_t *wstr = new wchar_t[len];
memset(wstr, 0, len*sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, 0, input.c_str(), -1, wstr, len);
CStringW output = wstr;
delete[] wstr;
return output;
#else
return CString(input.c_str());
#endif // !UNICODE
}