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

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

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

Post 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.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Post by mmvisual »

Yes, I have include ist in V6.6.6. It works now fine. No incompatibilities.

Best Regards Markus.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
mmvisual
Senior Boarder
Senior Boarder
Posts: 51
Joined: 13.10.2010, 14:55

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
Post Reply