MinimalECIInput constructor

MinimalECIInput(
  1. String stringToEncode,
  2. Encoding? priorityCharset,
  3. int fnc1
)

Constructs a minimal input

@param stringToEncode the character string to encode @param priorityCharset The preferred Charset. When the value of the argument is null, the algorithm chooses charsets that leads to a minimal representation. Otherwise the algorithm will use the priority charset to encode any character in the input that can be encoded by it if the charset is among the supported charsets. @param fnc1 denotes the character in the input that represents the FNC1 character or -1 if this is not GS1 input.

Implementation

MinimalECIInput(String stringToEncode, Encoding? priorityCharset, this.fnc1) {
  final encoderSet = ECIEncoderSet(stringToEncode, priorityCharset, fnc1);
  //optimization for the case when all can be encoded without ECI in ISO-8859-1
  if (encoderSet.length == 1) {
    bytes = List.filled(stringToEncode.length, 0);
    for (int i = 0; i < bytes.length; i++) {
      final c = stringToEncode.codeUnitAt(i);
      bytes[i] = c == fnc1 ? 1000 : c;
    }
  } else {
    bytes = encodeMinimally(stringToEncode, encoderSet, fnc1);
  }
}