convert method

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

Converts input and returns the result of the conversion.

Implementation

@override
List<int> convert(String input, [int start = 0, int? end]) {
  var runesList = input.runes.toList(growable: false);
  final usedEnd = RangeError.checkValidRange(start, end, runesList.length);
  if (start > 0 || usedEnd < runesList.length) {
    runesList = runesList.sublist(start, usedEnd);
  }
  for (var i = 0; i < runesList.length; i++) {
    final rune = runesList[i];
    if (rune > startIndex || (rune <= lowerEndIndex && rune > 0)) {
      final value = encodingMap[rune];
      if (value == null) {
        if (!allowInvalid) {
          throw FormatException(
              'Invalid value in input: "${String.fromCharCode(rune)}" '
              '/ ($rune) at index $i of "$input"');
        } else {
          runesList[i] = 0x3F; // ?
        }
      } else {
        runesList[i] = value;
      }
    }
  }
  return runesList;
}