std::string wstring2string(std::wstring wstr)
{
std::string result;
int len = WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), NULL, 0, NULL, NULL);
char* buffer = new char[len + 1];
WideCharToMultiByte(CP_ACP, 0, wstr.c_str(), wstr.size(), buffer, len, NULL, NULL);
buffer[len] = '\0';
result.append(buffer);
delete[] buffer;
return result;
}
std::wstring utf8string2wstring(const std::string& str)
{
static std::wstring_convert< std::codecvt_utf8<wchar_t> > strCnv;
return strCnv.from_bytes(str);
}
size_t CurlWriteCallback(char* buf, size_t size, size_t nmemb, void* up)
{
buf[nmemb] = '\0';
g_str_ret = buf;
wstring ss = utf8string2wstring(g_str_ret);
g_str_ret = wstring2string(ss);
return size * nmemb;
}