MinimalEncoder class

Encoder that encodes minimally

Algorithm:

Uses Dijkstra to produce mathematically minimal encodings that are in some cases smaller than the results produced by the algorithm described in annex S in the specification ISO/IEC 16022:200(E). The biggest improvment of this algorithm over that one is the case when the algorithm enters the most inefficient mode, the B256 mode. The algorithm from the specification algorithm will exit this mode only if it encounters digits so that arbitrarily inefficient results can be produced if the postfix contains no digits.

Multi ECI support and ECI switching:

For multi language content the algorithm selects the most compact representation using ECI modes. Note that unlike the compaction algorithm used for QR-Codes, this implementation operates in two stages and therfore is not mathematically optimal. In the first stage, the input string is encoded minimally as a stream of ECI character set selectors and bytes encoded in the selected encoding. In this stage the algorithm might for example decide to encode ocurrences of the characters "\u0150\u015C" (O-double-acute, S-circumflex) in UTF-8 by a single ECI or alternatively by multiple ECIs that switch between IS0-8859-2 and ISO-8859-3 (e.g. in the case that the input contains many * characters from ISO-8859-2 (Latin 2) and few from ISO-8859-3 (Latin 3)). In a second stage this stream of ECIs and bytes is minimally encoded using the various Data Matrix encoding modes. While both stages encode mathematically minimally it is not ensured that the result is mathematically minimal since the size growth for inserting an ECI in the first stage can only be approximated as the first stage does not know in which mode the ECI will occur in the second stage (may, or may not require an extra latch to ASCII depending on the current mode). The reason for this shortcoming are difficulties in implementing it in a straightforward and readable manner.

GS1 support

FNC1 delimiters can be encoded in the input string by using the FNC1 character specified in the encoding function. When a FNC1 character is specified then a leading FNC1 will be encoded and all ocurrences of delimiter characters while result in FNC1 codewords in the symbol.

@author Alex Geller

Constructors

MinimalEncoder()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

c40Shift2Chars List<int>
final

Static Methods

addEdge(List<List<Edge?>> edges, Edge edge) → void
addEdges(Input input, List<List<Edge?>> edges, int from, Edge? previous) → void
encode(String input, Encoding? priorityCharset, int fnc1, SymbolShapeHint shape, int macroId) Uint8List
Encodes input minimally and returns an array of the codewords
encodeHighLevel(String msg, [Encoding? priorityCharset, int fnc1 = -1, SymbolShapeHint shape = SymbolShapeHint.forceNone]) String
Performs message encoding of a DataMatrix message
encodeMinimally(Input input) Result
getNumberOfC40Words(Input input, int from, bool c40, List<int> characterLength) int
The number of characters encoded is returned in characterLength. The number of characters encoded is also minimal in the sense that the algorithm stops as soon as a character encoding fills a C40 word competely (three C40 values). An exception is at the end of the string where two C40 values are allowed (according to the spec the third c40 value is filled with 0 (Shift 1) in this case).
isExtendedASCII(int ch, int fnc1) bool
isInC40Shift1Set(int ch) bool
isInC40Shift2Set(int ch, int fnc1) bool
isInTextShift1Set(int ch) bool
isInTextShift2Set(int ch, int fnc1) bool