encodeCString static method

Uint8List encodeCString(
  1. String s
)

Encodes s as NUL-terminated UTF-8 bytes (not yet in the heap — copy in via a WasmArena or writeBytes).

Implementation

static Uint8List encodeCString(String s) {
  final utf8 = const Utf8Encoder().convert(s);
  final out = Uint8List(utf8.length + 1);
  out.setRange(0, utf8.length, utf8);
  return out;
}