appendFLGn method

State appendFLGn(
  1. int eci
)

Implementation

State appendFLGn(int eci) {
  // 0: FLG(n)
  final result = shiftAndAppend(HighLevelEncoderMode.punct, 0);
  Token token = result._token;
  int bitsAdded = 3;
  if (eci < 0) {
    token = token.add(0, 3); // 0: FNC1
  } else if (eci > 999999) {
    throw ArgumentError('ECI code must be between 0 and 999999');
  } else {
    final eciDigits = latin1.encode(eci.toString());
    token = token.add(eciDigits.length, 3); // 1-6: number of ECI digits
    for (int eciDigit in eciDigits) {
      token = token.add(eciDigit - 48 /*'0'*/ + 2, 4);
    }
    bitsAdded += eciDigits.length * 4;
  }
  return State(token, _mode, 0, _bitCount + bitsAdded);
}