Unicode使用sqlite3,支持中文字符

Unicode下使用sqlite3,两个重要函数,供参考。
demo下载:https://download.csdn.net/download/u012033076/12336370
2020年4月27日17:37:19 补充:在执行查询时,将下面这句话中的strSql.GetLength()替换为-1;
rc = sqlite3_prepare(pDB,MbcsToUtf8(c2),-1/*strSql.GetLength()*/, &pstmt, &errMsg);

CStringA CDataBaseHelper::getSqliteString( const unsigned char* chData ) { int len = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)chData, -1, NULL, 0); wchar_t* pUnicode = newwchar_t[len+1]; memset(pUnicode,0,(len+1)*sizeof(wchar_t)); MultiByteToWideChar(CP_UTF8, 0,(LPCSTR)chData, -1, (LPWSTR)pUnicode, len); wstring strUnicode = ( wchar_t* )pUnicode; delete pUnicode; CStringA strData(strUnicode.c_str()); return strData; }CStringA CDataBaseHelper::MbcsToUtf8( const char *file ) { CStringA str; WCHAR*pwchar=0; CHAR*pchar=0; int len=0; int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; len=MultiByteToWideChar(codepage, 0, file, -1, NULL,0); pwchar=new WCHAR[len]; if(pwchar!=0) { len = MultiByteToWideChar(codepage, 0, file, -1, pwchar, len); if( len!=0 ) { len = WideCharToMultiByte(CP_UTF8, 0, pwchar, -1, 0, 0, 0, 0); pchar=new CHAR[len]; if(pchar!=0) { len = WideCharToMultiByte(CP_UTF8, 0, pwchar, -1, pchar, len,0, 0); if(len!=0) { str=pchar; } delete pchar; } delete pwchar; } } return str; }


【Unicode使用sqlite3,支持中文字符】

    推荐阅读