assignString method

void assignString(
  1. String value
)

Replaces the contents with value encoded as UTF-8, growing storage if it must. Throws SofabError.invalidArgument for an unpaired surrogate.

Implementation

void assignString(String value) {
  final bytes = encodeUtf8Strict(value);
  if (bytes == null) {
    throw const SofabException(
      SofabError.invalidArgument,
      'string is not valid UTF-8 (unpaired surrogate)',
    );
  }
  assign(bytes);
}