convert method

  1. @override
String convert(
  1. List<int> input, [
  2. int start = 0,
  3. int? end
])
override

Converts input and returns the result of the conversion.

Implementation

@override
String convert(List<int> input, [int start = 0, int? end]) {
  end = RangeError.checkValidRange(start, end, input.length);
  List<int>? modified;

  for (var i = start; i < end; i++) {
    var byte = input[i];

    if (byte & ~0xFF != 0) {
      if (allowInvalid) {
        modified ??= input.toList(growable: false);
        modified[i] = 0xFFFD;
      } else {
        throw FormatException('Invalid value in input: $byte');
      }
    } else if (byte > 0x7F) {
      modified ??= input.toList(growable: false);
      modified[i] = symbols[byte - 0x80];
    }
  }

  return String.fromCharCodes(modified ?? input, start, end);
}