64,632
社区成员
发帖
与我相关
我的任务
分享
rapidjson::Document doc_config;
int ret = GetDocumentFromJsonFile(path, doc_config);
const rapidjson::Value& myValue = doc_config["myKey"];
std::string data = testing["mySubkey"].GetString(); //here
//data 如果存在中文就会乱码,应该怎样转换处理呢?谢谢!
wstring StringHelper::UTF8ToUnicode( const string & s)
{
wstring result;
int n = MultiByteToWideChar( CP_UTF8, 0, s.c_str(), -1, NULL, 0 );
wchar_t * buffer = new wchar_t[n];
::MultiByteToWideChar( CP_UTF8, 0, s.c_str(), -1, buffer, n );
result = buffer;
delete[] buffer;
return result;
}
std::string WChar2Ansi(LPCWSTR pwszSrc)
{
int nLen = 0;
nLen = WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, NULL, 0, NULL, NULL);
if (nLen<= 0)
return std::string("");
char* pszDst = new char[nLen];
if (NULL == pszDst)
return std::string("");
WideCharToMultiByte(CP_ACP, 0, pwszSrc, -1, pszDst, nLen, NULL, NULL);
pszDst[nLen -1] = 0;
std::string strTemp(pszDst);
delete [] pszDst;
return strTemp;
}