MinimalEncoder (ZXing 3.5.0 API)

com.google.zxing.datamatrix.encoder

## Class MinimalEncoder

- java.lang.Object
- - com.google.zxing.datamatrix.encoder.MinimalEncoder

-     public final class MinimalEncoder
      extends Object

  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 "ŐŜ" (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

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static String` | `encodeHighLevel(String msg)` Performs message encoding of a DataMatrix message
    `static String` | `encodeHighLevel(String msg, Charset priorityCharset, int fnc1, SymbolShapeHint shape)` Performs message encoding of a DataMatrix message

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### encodeHighLevel

          public static String encodeHighLevel(String msg)

      Performs message encoding of a DataMatrix message
      Parameters:
        `msg` - the message
      Returns:
        the encoded message (the char values range from 0 to 255)

    - #### encodeHighLevel

          public static String encodeHighLevel(String msg,
                                               Charset priorityCharset,
                                               int fnc1,
                                               SymbolShapeHint shape)

      Performs message encoding of a DataMatrix message
      Parameters:
        `msg` - the message
        `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.
        `fnc1` - denotes the character in the input that represents the FNC1 character or -1 if this is not a GS1 bar code. If the value is not -1 then a FNC1 is also prepended.
        `shape` - requested shape.
      Returns:
        the encoded message (the char values range from 0 to 255)

Copyright © 2007–2022. All rights reserved.