sqlite3_open打开数据库失败 返回值14问题

原因:sqlite3_open第一个参数路径中有中文字符,而它只支持UTF-8编码,所以使数据库打开失败

解决:我在网上找的转码,先把路径转码。

CString 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,arial; font-size:14px; line-height:21px"> pchar=new CHAR[len];
if(pchar!=0)
{
len = WideCharToMultiByte(CP_UTF8,pchar,len,arial; font-size:14px; line-height:21px"> if(len!=0)
{
str=pchar;
}
delete pchar;
}
delete pwchar;
}
}
return str;
}

相关文章

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