setString method

void setString(
  1. String value, [
  2. BufferEncoding encoding = BufferEncoding.utf8
])

Writes an `encoded value to a region of the buffer.

Returns the position of the last element written to the buffer (offset + decoded-length).

The encoded value is written to the range [offset : offset+length]. If length is omitted, the range extends to the end of the buffer.

The range must satisy the relations 0offsetoffset+lengththis.length.

Implementation

void setString(
  final String value, [
  final BufferEncoding encoding = BufferEncoding.utf8,
]) {
  final Iterable<int> bytes = Buffer.fromString(value, encoding);
  setBuffer(bytes);
}