sqlite3问题2:中文路径的支持

在工程中加sqlite3源代码,调用第一个函数sqlite3_open,发现其不支持中文路径。 经过检索发现该函数要求输入的文件名为utf8编码。 //再sqlite3.c中 winFullPathname、sqlite3_win32_mbcs_to_utf8、mbcsToUnicode、unicodeToUtf8与此事相关。 //参考以上4个函数,做的一个编码转换函数 CString CMyApp::MbcsToUtf8(const char *file) { CString str; WCHAR *pwchar=0; CHAR *pchar=0; int len=0; int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP; len=MultiByteToWideChar(codepage,file,-1,NULL,0); pwchar=new WCHAR[len]; if(pwchar!=0) { len = MultiByteToWideChar(codepage,pwchar,len); if( len!=0 ) { len = WideCharToMultiByte(CP_UTF8,0); pchar=new CHAR[len]; if(pchar!=0) { len = WideCharToMultiByte(CP_UTF8,pchar,len,0); if(len!=0) { str=pchar; } delete pchar; } delete pwchar; } } return str; }

相关文章

SQLite架构简单,又有Json计算能力,有时会承担Json文件/RES...
使用Python操作内置数据库SQLite以及MySQL数据库。
破解微信数据库密码,用python导出微信聊天记录
(Unity)SQLite 是一个软件库,实现了自给自足的、无服务器...
安卓开发,利用SQLite实现登陆注册功能