convert method
Converts input
and returns the result of the conversion.
Implementation
@override
convert(input) {
List<int> result = [];
for (int i = 0; i < input.length; i++) {
final c1 = input[i];
List<int>? c2;
if (c1 <= 0x7F) {
// ASCII Compatible (partially)
c2 = utfToShiftJisTable[c1];
} else if (c1 >= 0xa1 && c1 <= 0xdf) {
// Half-width Hiragana
c2 = utfToShiftJisTable[c1];
} else if (c1 >= 0x81 && c1 <= 0x9f) {
// JIS X 0208
c2 = utfToShiftJisTable[(c1 << 8) + input[++i]];
} else if (c1 >= 0xe0 && c1 <= 0xef) {
// JIS X 0208
c2 = utfToShiftJisTable[(c1 << 8) + input[++i]];
} else {
// Unknown
}
if (c2 != null) {
result.addAll(c2);
} else if (_allowMalformed) {
result.add(unicodeReplacementCharacterRune);
} else {
throw FormatException('Unfinished Shift-JIS octet sequence', input, i);
}
}
return utf8.decode(result, allowMalformed: _allowMalformed);
}