convert method

  1. @override
String convert(
  1. List<int> input
)
override

Converts input and returns the result of the conversion.

Implementation

@override
convert(input) {
  List<int> result = [];
  for (int i = 0; i < input.length; i++) {
    var c1 = input[i];
    if (c1 <= 0x7F) {
      // ASCII Compatible (partially)
      result.addAll(JIS_TABLE[c1] ?? []);
    } else if (c1 >= 0xa1 && c1 <= 0xdf) {
      // Half-width Hiragana
      result.addAll(JIS_TABLE[c1] ?? []);
    } else if (c1 >= 0x81 && c1 <= 0x9f) {
      // JIS X 0208
      var c2 = input[++i];
      result.addAll(JIS_TABLE[(c1 << 8) + c2] ?? []);
    } else if (c1 >= 0xe0 && c1 <= 0xef) {
      // JIS X 0208
      var c2 = input[++i];
      result.addAll(JIS_TABLE[(c1 << 8) + c2] ?? []);
    } else {
      // Unknown
      result.addAll([]);
    }
  }
  return utf8.decode(result);
}