convert method

String convert (List<int> bytes, [ int start = 0, int end ])
inherited

Converts the bytes (a list of unsigned 7- or 8-bit integers) to the corresponding string.

If start and end are provided, only the sub-list of bytes from start to end (end not inclusive) is used as input to the conversion.

Implementation

String convert(List<int> bytes, [int start = 0, int end]) {
  var byteCount = bytes.length;
  RangeError.checkValidRange(start, end, byteCount);
  end ??= byteCount;

  for (var i = start; i < end; i++) {
    var byte = bytes[i];
    if ((byte & ~_subsetMask) != 0) {
      if (!_allowInvalid) {
        throw FormatException("Invalid value in input: $byte");
      }
      return _convertInvalid(bytes, start, end);
    }
  }
  return String.fromCharCodes(bytes, start, end);
}