Unicode转GBK
std::string UnicodeTo(std::string sUnicode)
{
std::string sgbk = sUnicode;
//printf("unicode:%s\n", sgbk.c_str());
setlocale(LC_ALL, "");
int npos = sgbk.find("\\u");
while(npos != std::string::npos)
{
if(sgbk.length() - npos < 6)
break;
char sGBK[5]; memset(sGBK, 0, 5);
wchar_t ws[2]; memset(ws, 0, 2);
ws[0] = strtol(sgbk.substr(npos+2, 4).c_str(), NULL, 16);
wcstombs(sGBK, ws, 5);
//printf("<%s %s>", sgbk.substr(npos+2, 4).c_str(), sGBK);
std::string stemp = sgbk.substr(0, npos);
stemp += sGBK;
if(npos+6 < sgbk.length())
stemp += sgbk.substr(npos+6, sgbk.length()-npos-6);
sgbk = stemp;
//printf("%s\n", sgbk.c_str());
npos = sgbk.find("\\u");
}
return sgbk;
}