convert method

  1. @override
Iterable<bool> convert(
  1. String data
)
override

Implementation

@override
Iterable<bool> convert(String data) sync* {
  yield* add(BarcodeMaps.telepenStart, BarcodeMaps.telepenLen);

  int checksum = 0;

  for (final int code in data.codeUnits) {
    if (code >= BarcodeMaps.telepen.length) {
      throw BarcodeException('Unable to encode "${String.fromCharCode(code)}" to $name Barcode');
    }
    final int codeValue = BarcodeMaps.telepen[code];
    yield* add(codeValue, BarcodeMaps.telepenLen);
    checksum += code;
  }

  checksum = 127 - (checksum % 127);
  if (checksum == 127) {
    checksum = 0;
  }
  yield* add(BarcodeMaps.telepen[checksum], BarcodeMaps.telepenLen);

  yield* add(BarcodeMaps.telepenEnd, BarcodeMaps.telepenLen);
}