dart-lang / dart-lang/native

FFI API Issue on Windows - Strings and Unicode?

Open
#916 4 comments 0 reactions 0 assignees View on GitHub
package:ffi
Dominant language
Dart
Stars
275
Forks
144
Avg merge
2d 10h
Merged PRs (30d)
47

Description

Hello team,

Excuse the confusing title, but this is an issue that I'm not quite sure where it stems from and just have guesses. I'm working on migrating [flutter_storm](https://github.com/HarbourMasters64/flutter_storm), a bridge for [StormLib](), from using native bindings to FFI. However I'm running into a an issue (only on Windows).

If you try the example project in the `flutter_storm` and try to open a test archive ([Test.mpq.zip](https://github.com/dart-lang/ffi/files/10547607/Test.mpq.zip)), it'll fail on Windows. After some research I found a similar issue on their issue tracker: https://github.com/ladislav-zezula/StormLib/issues/260 which ended up being an issue between using `LPStr` and `LPWStr` which led me to explore how FFI is doing string conversions.

`ffigen` generated uses of `Pointer` for me -- I've also tried using Pointer but cannot get it to succeed on Windows. I unfortunately also cannot figure out how to debug ffi conversions and internals. Would love for some advicement or help here. From dart I'm converting to native with `toNativeUtf8().cast()`.

Here's the branch of `flutter_storm` where I'm doing the migration to ffi: https://github.com/HarbourMasters64/flutter_storm/tree/feature/ffi

Here's the branch where I've attempted to use `Pointer` to no avail:
https://github.com/HarbourMasters64/flutter_storm/tree/feature/ffi-utf8

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.