mysql
m_pDB->execute("SET character set gbk");//先使用这句话设置为gbk编码,使以后的query结果集为gbk
然后使用此函数转化(此函数为网上摘取,感谢原创)
CStringW convertStringA2W(CStringA srcStr)
{
wchar_t wc[MAX_PATH];
MultiByteToWideChar(CP_ACP, 0, (LPCSTR) srcStr, -1, wc, MAX_PATH);
CStringW dstStr;
dstStr.Format(L"%s", wc);
return dstStr;
}
例如:
sql::ResultSet* res;
m_pDB->execute("SET character set gbk");
res = m_pDB->executeQuery("select name from Tbl_name");
CStringW Name = convertStringA2W((CStringA)res->getString("District_Name").c_str());