getLatchBytes method

Uint8List getLatchBytes()

Implementation

Uint8List getLatchBytes() {
  switch (previousMode) {
    case Mode.ascii:
    case Mode.b256: //after B256 ends (via length) we are back to ASCII
      switch (mode) {
        case Mode.b256:
          return getBytes(231);
        case Mode.c40:
          return getBytes(230);
        case Mode.text:
          return getBytes(239);
        case Mode.x12:
          return getBytes(238);
        case Mode.edf:
          return getBytes(240);
        case Mode.ascii:
          break;
      }
      break;
    case Mode.c40:
    case Mode.text:
    case Mode.x12:
      if (mode != previousMode) {
        switch (mode) {
          case Mode.ascii:
            return getBytes(254);
          case Mode.b256:
            return getBytes(254, 231);
          case Mode.c40:
            return getBytes(254, 230);
          case Mode.text:
            return getBytes(254, 239);
          case Mode.x12:
            return getBytes(254, 238);
          case Mode.edf:
            return getBytes(254, 240);
        }
      }
      break;
    case Mode.edf:
      //The rightmost EDIFACT edge always contains an unlatch character
      assert(mode == Mode.edf);
      break;
  }
  return Uint8List(0);
}