Cannot open SQLite Database with UTF-8 Filename (Lazarus)
Posted: 24.07.2011, 07:19
Hello,
My Path is: "J:\TestInstall\Neuer Ordner\undÜ ü ßß ö Ö ż łćó ss"
This Path contains characters where are not codet in the Ansi Character Set.
But the SQLite DLL can this characters. I have change one line in the code, just ist work better:
src\plain\ZPlainSqLiteDriver.pas
function TZSQLite3PlainDriver.Open(const filename: PChar; mode: Integer;
var errmsg: PChar): Psqlite;
var
Result0: Psqlite;
Version: string;
FileNameString: String;
begin
Result0:= nil;
Version := LibVersion;
FileNameString := filename;
{$IFNDEF VER130}
if (Version > '3.2.5') then
{$IFDEF FPC}
ZPlainSqLite3.sqlite_open(FileNameString, Result0) // Lazarus nuzt direkt UTL-8 so auch SQLite.dll
{$ELSE}
ZPlainSqLite3.sqlite_open(PAnsiChar(AnsiToUTF8(FileNameString)), Result0)
{$ENDIF}
else
{$ENDIF}
ZPlainSqLite3.sqlite_open(filename, Result0);
Result := Result0;
end;
Please include it into your main sources.
Best Regards Markus.
My Path is: "J:\TestInstall\Neuer Ordner\undÜ ü ßß ö Ö ż łćó ss"
This Path contains characters where are not codet in the Ansi Character Set.
But the SQLite DLL can this characters. I have change one line in the code, just ist work better:
src\plain\ZPlainSqLiteDriver.pas
function TZSQLite3PlainDriver.Open(const filename: PChar; mode: Integer;
var errmsg: PChar): Psqlite;
var
Result0: Psqlite;
Version: string;
FileNameString: String;
begin
Result0:= nil;
Version := LibVersion;
FileNameString := filename;
{$IFNDEF VER130}
if (Version > '3.2.5') then
{$IFDEF FPC}
ZPlainSqLite3.sqlite_open(FileNameString, Result0) // Lazarus nuzt direkt UTL-8 so auch SQLite.dll
{$ELSE}
ZPlainSqLite3.sqlite_open(PAnsiChar(AnsiToUTF8(FileNameString)), Result0)
{$ENDIF}
else
{$ENDIF}
ZPlainSqLite3.sqlite_open(filename, Result0);
Result := Result0;
end;
Please include it into your main sources.
Best Regards Markus.