Make it easier to convert fixed size char arrays to Dart String
- Dominant language
- Dart
- Stars
- 275
- Forks
- 144
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 47
Description
I have the following definition for a C struct that is returned by a C function:
```
struct devinfo {
char serial[SERIAL_LENGTH];
// ...
};
```
ffigen creates the following code for me:
```
class devinfo extends ffi.Struct {
@ffi.Array.multi([33])
external ffi.Array serial;
// ...
};
```
I don't know of any conversion to a Dart string here other than something like this:
```
String arrayToString(Array array) {
final stringList = [];
var i = 0;
while (array[i] != 0) {
stringList.add(array[i]);
i++;
}
return String.fromCharCodes(stringList);
}
```
Shouldn't such conversions be easy one-liners provided by ffi or ffigen? Or am I missing something?
Contributor guide
Assessment
This issue has not been assessed yet.