W3cubDocs

/Dart 2

convert method

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

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]) {
  int byteCount = bytes.length;
  RangeError.checkValidRange(start, end, byteCount);
  if (end == null) end = byteCount;

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

© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/2.0.0/dart-convert/AsciiDecoder/convert.html