BOOL Sqlite3DB::ExecuteSQL( LPCWSTR unicodeSql, int* pAffectedRows /*= NULL*/ ) { std::string utf8Sql; if (! Unicode2Utf8(unicodeSql, utf8Sql)) { return FALSE; } return ExecuteSQL(utf8Sql.c_str(), pAffectedRows); }
BOOL Sqlite3DB::AddSql2Queue( LPCWSTR sql ) { std::string utf8Sql; if (! Unicode2Utf8(sql, utf8Sql)) { return FALSE; } AddSql2Queue(utf8Sql.c_str()); return TRUE; }
//ascii 转 Utf8 string ASCII2UTF_8(string& strAsciiCode) { string strRet(""); //先把 ascii 转为 unicode wstring wstr = Acsi2WideByte(strAsciiCode); //最后把 unicode 转为 utf8 strRet = Unicode2Utf8(wstr); return strRet; }
AString Converter::ASCII2UTF_8(const AString& strAsciiCode) { AString strRet(""); //先把 ascii 转为 unicode WString wstr = Acsi2WideByte(strAsciiCode); //最后把 unicode 转为 utf8 strRet = Unicode2Utf8(wstr); return strRet; }
BOOL Sqlite3DB::Open( LPCTSTR filepath ) { Close(); SQLTRY(); std::string utf8Filepath; if (! Unicode2Utf8(filepath, utf8Filepath)) { errorLog(_T("can not transfer [%s] to utf8"), filepath); return FALSE; } int iRet = sqlite3_open(utf8Filepath.c_str(), &m_pDB); if(iRet != SQLITE_OK) { errorLogE(_T("Cannot open db[%s]: %s."), filepath, CString(sqlite3_errmsg(m_pDB))); return FALSE; } SQLCACHE_RETFALSE(_T("open db")); return TRUE; }