We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dfb451b commit 1af428dCopy full SHA for 1af428d
1 file changed
lib/src/extensions/string.dart
@@ -1,21 +1,10 @@
1
// See: https://github.com/dart-lang/ffigen/issues/72
2
3
import 'dart:ffi';
4
-import 'dart:io';
5
6
import 'package:ffi/ffi.dart';
7
8
extension CharPointer on String {
9
- Pointer<Char> toCharPointer(Allocator allocator) {
10
- if (Platform.isWindows) {
11
- final bytes = systemEncoding.encode(this);
12
- final pointer = allocator<Uint8>(bytes.length + 1);
13
- final buffer = pointer.asTypedList(bytes.length + 1);
14
- buffer.setAll(0, bytes);
15
- buffer[bytes.length] = 0;
16
- return pointer.cast<Char>();
17
- }
18
-
19
- return toNativeUtf8(allocator: allocator).cast<Char>();
20
+ Pointer<Char> toCharPointer(Allocator allocator) =>
+ toNativeUtf8(allocator: allocator).cast<Char>();
21
}
0 commit comments