sqlite数据库支持中文路径问题

前端之家收集整理的这篇文章主要介绍了sqlite数据库支持中文路径问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

char *unicodeToUtf8(const WCHAR *zWideFilename){
int nByte;
char *zFilename;

nByte = WideCharToMultiByte(CP_UTF8,zWideFilename,-1,0);
zFilename = (char*)malloc( nByte );
if( zFilename==0 ){
return 0;
}
nByte = WideCharToMultiByte(CP_UTF8,zFilename,nByte,
0,0);
if( nByte == 0 ){
free(zFilename);
zFilename = 0;
}
return zFilename;
}

WCHAR *mbcsToUnicode(const char *zFilename){
int nByte;
WCHAR *zMbcsFilename;
int codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;

nByte = MultiByteToWideChar(codepage,NULL,0)*sizeof(WCHAR);
zMbcsFilename = (WCHAR*)malloc( nByte*sizeof(zMbcsFilename[0]) );
if( zMbcsFilename==0 ){
return 0;
}
nByte = MultiByteToWideChar(codepage,zMbcsFilename,nByte);
if( nByte==0 ){
free(zMbcsFilename);
zMbcsFilename = 0;
}
return zMbcsFilename;
}

char szPath[256] = "D://Project//Test//wwtest//DBTest//DBTest//我的数据库//pic.db"; char *pPath; WCHAR *wcPath; wcPath = mbcsToUnicode(szPath); pPath = unicodeToUtf8(wcPath); sqlite3_open(pPath,&db);

原文链接:https://www.f2er.com/sqlite/202295.html

猜你在找的Sqlite相关文章