decodeUtf8 function

String decodeUtf8(
  1. List<int> bytes, [
  2. int offset = 0,
  3. int? length,
  4. int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT,
])

Produce a String from a List of UTF-8 encoded bytes. The parameters can set an offset into a list of bytes (as int), limit the length of the values to be decoded, and override the default Unicode replacement character. Set the replacementCharacter to null to throw an ArgumentError rather than replace the bad value.

Implementation

String decodeUtf8(List<int> bytes,
    [int offset = 0,
    int? length,
    int replacementCodepoint = UNICODE_REPLACEMENT_CHARACTER_CODEPOINT]) {
  return String.fromCharCodes(
      (Utf8Decoder(bytes, offset, length, replacementCodepoint)).decodeRest().whereType<int>());
}