#ifdef Q_OS_WIN
#include <iostream>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <windows.h>
//using namespace std;
static std::string GBK2UTF8(const std::string &gbkStr)
{
std::string outUtf8 = "";
int n = MultiByteToWideChar(CP_ACP, 0, gbkStr.c_str(), -1, NULL, 0);
WCHAR *str1 = new WCHAR[n];
MultiByteToWideChar(CP_ACP, 0, gbkStr.c_str(), -1, str1, n);
n = WideCharToMultiByte(CP_UTF8, 0, str1, -1, NULL, 0, NULL, NULL);
char *str2 = new char[n];
WideCharToMultiByte(CP_UTF8, 0, str1, -1, str2, n, NULL, NULL);
outUtf8 = str2;
delete[]str1;
str1 = NULL;
delete[]str2;
str2 = NULL;
return outUtf8;
}
std::string UTF8_2_GBK(const std::string &utf8Str)
{
std::string outGBK = "";
int n = MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, NULL, 0);
WCHAR *str1 = new WCHAR[n];
MultiByteToWideChar(CP_UTF8, 0, utf8Str.c_str(), -1, str1, n);
n = WideCharToMultiByte(CP_ACP, 0, str1, -1, NULL, 0, NULL, NULL);
char *str2 = new char[n];
WideCharToMultiByte(CP_ACP, 0, str1, -1, str2, n, NULL, NULL);
outGBK = str2;
delete[] str1;
str1 = NULL;
delete[] str2;
str2 = NULL;
return outGBK;
}
#endif