Page 1 of 1

Cannot open SQLite Database with UTF-8 Filename (Lazarus)

Posted: 24.07.2011, 07:19
by mmvisual
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.

Posted: 31.10.2011, 00:09
by mdaems
Hi Markus,

I think you tried this in the zeoslib 6.6 version. Would it be a safe thing to add this change to a stable release? No incompatibilities with existing code?

I did commit a slightly modified patch to testing branch already (SVN rev. 956)

Mark

Posted: 31.10.2011, 07:17
by mmvisual
Yes, I have include ist in V6.6.6. It works now fine. No incompatibilities.

Best Regards Markus.

Posted: 08.11.2011, 21:08
by mdaems
Markus,

This is strange. Why am I getting this error line?
ZPlainSqLiteDriver.pas(840,47) Error: Incompatible types: got "AnsiString" expected "PChar"
on line

Code: Select all

ZPlainSqLite3.sqlite_open(FileNameString, Result0) // Lazarus nuzt direkt UTL-8 so auch SQLite.dll 
I'm using compiler version 2.7.1, so it can be a bug in fpc, but indeed, we're passing a string variable to a OChar parameter, so that's not nice anyway. Should I suround this by PAnsiChar()?

Mark

Posted: 08.11.2011, 21:21
by mmvisual
I use the same FPC Version and it works good.

In attachmet is my complete src folder, then you can see my changes from the file timestamp.

Best regards, Markus.

Posted: 08.11.2011, 21:48
by mdaems
OK. See the difference...
In your post :
ZPlainSqLite3.sqlite_open(FileNameString, Result0) // Lazarus nuzt direkt UTL-8 so auch SQLite.dll
In your code:
ZPlainSqLite3.sqlite_open(PAnsiChar(FileNameString), Result0) // Lazarus nuzt direkt UTL-8 so auch SQLite.dll
I'll test when current test run is over and probably commit in half an hour to 6.6-patches.

Mark