toUtf16Buffer method

Pointer<Uint16> toUtf16Buffer()

Returns an allocator-allocated pointer to the result.

Implementation

Pointer<Uint16> toUtf16Buffer() {
  final count = length + 1;
  final Pointer<Uint16> result = calloc<Uint16>(count);
  final Uint16List typedList = result.asTypedList(count);
  typedList.setAll(0, this);
  typedList[length] = 0;
  return result;
}