Better string support if all strings in a C API follow the same encoding
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
If we have a header file for which we know all the `char*` are UTF-8 null-terminated strings, we can do the following:
```c
int my_strlen(char *a);
char *my_substr(char *a, int start, int end);
```
```yaml
type-map:
native-types:
'char':
'lib': 'pkg_ffi'
'c-type': 'Utf8'
'dart-type': 'Utf8'
```
However, this does not support any `char` (without `*`) in the API.
The following doesn't work:
```yaml
type-map:
native-types:
'char*':
'lib': 'dart_ffi'
'c-type': 'Pointer'
'dart-type': 'Pointer'
```
Matching on `char*` isn't supported.
Also, there's no way to filter only replacing the type in certain functions but not everywhere.
For libraries that do not have any `char` in their API, and for which all `char*` are consistently `Pointer` this works though.
Contributor guide
Assessment
This issue has not been assessed yet.