I’m trying to hook into a C DLL and of course it uses UTF8.

In Delphi you would do something like:

iResult := SQLite3_Open(PAnsiChar(UTF8String(FileName)), Fdb);

In Oxygene would you do

type PAnsiChar = ^AnsiChar;

var lBytes := Encoding.UTF8.GetBytes( AString );
iResult := SQLite3_Open(PAnsiChar( lBytes ), Fdb);

Be nice if there was just UTF8String

Trying not to use the Delphi.RTL

i think the problem with that approach, on island, would be: who owns/frees the returned memory? @ck?

Oh this could work fine, we just need to write the utf8string type. Elements doesn’t free temp vars until the end of the scope

well, the ting is it wouldn’t be a class, but it’d return a pansichar?

Implicit conversion from utf8string to pansichar would fix that.

hmm, ok… and who controls who owns the. emory of that pansichar, once it’s passed on?

the cast to UTF8String would hold the pansichar (it’d be a struct with an array of ansichar inside it). It would get freed some time after the call (end of scope).

Thanks, logged as bugs://82664

lol… so what’s the story… I new UTF8String on the way :slight_smile:

we’re still in the design phase of this, but I’m thinking something like that yes.

Is this issue related ?

SQLite3DLL = public static class //public class
[DllImport( SQLiteDLL_Name )]


//[DllImport(SQLiteDLL_Name, EntryPoint := 'sqlite3_initialize')]
class method sqlite3_initialize(): Integer; external; // SQLiteDLL name 'sqlite3_initialize';

but when accessing:

E: undefined symbol: _sqlite3_initialize

Not really no. What platform?


:slight_smile: Sorry I mean i386 vs x86_64 and Windows vs Linux?

Sorry… windows x86
I can send you the code
Basically just hooking intro he SQLite.DLL

That’d be cool. I don’t have (current) issues related to DllImport and having a tsetcase makes this a lot easier to fix.

Sorry for delay Carlo. Had to put together a test case. Buggered if I can get this DLL to hook in. Have tried several things as per test code attached. Clearly doing something wrong.

SQLite test.zip (1.0 MB)

Thanks, logged as bugs://82675 (for sqlite interop). Do note that we have an sqlite.fx that should already link in sqlite, without a dependency on the dll.

I can’t seem to get the undefined export issue you were talking about … I do get an access violation though, this because sqlite3_version is a variable not a function. You can use the libversion api to get the version as function:

SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; // <<< variable
SQLITE_API const char *sqlite3_libversion(void); // api that returns above
SQLITE_API const char *sqlite3_sourceid(void);
SQLITE_API int sqlite3_libversion_number(void);

bugs://82675 got closed with status cannotrepro.