Skip to content

Commit 1af428d

Browse files
committed
remove Windows-specific handling in toCharPointer method
1 parent dfb451b commit 1af428d

1 file changed

Lines changed: 2 additions & 13 deletions

File tree

lib/src/extensions/string.dart

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
// See: https://github.com/dart-lang/ffigen/issues/72
22

33
import 'dart:ffi';
4-
import 'dart:io';
54

65
import 'package:ffi/ffi.dart';
76

87
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-
}
8+
Pointer<Char> toCharPointer(Allocator allocator) =>
9+
toNativeUtf8(allocator: allocator).cast<Char>();
2110
}

0 commit comments

Comments
 (0)