The recent use of SQLite as a database, found that if the direct delivery of a database with Chinese path or file name, will cause the database can not open the situation.
Looked at the source of SQLite, only to find that the original SQLite is used UTF8 encoding file open operation.
So, when you pass a file name, you need to encode it. In Delphi, use the following function.
function Translatedbfile (str:string): string;
Var
tmp:utf8string;
L:integer;
L_widestring:pwidechar;
L_length:integer;
Begin
If Isenglishstring (STR) Then
Result: = Str
Else
Begin
L_length: = Length (STR) * 2;
Getmem (l_widestring, l_length);
Stringtowidechar (Str, l_widestring, l_length);
Result: = Utf8encode (STR);
Getmem (l_widestring, 0);
End
End
The Stringtowidechar and Utf8encode are included in the D7 system unit. Simple and convenient.
Http://www.cnblogs.com/qiubole/archive/2007/11/07/951807.html
SQLite Support for Chinese paths (used by Stringtowidechar and Utf8encode in the D7 system unit)