Crate datamatrix[][src]

Data Matrix (ECC 200) decoding and encoding library with an optimizing encoder.

Usage example

let bitmap = datamatrix::encode(
    b"Hello, World!",
    SymbolSize::Min,
).unwrap();
print!("{}", bitmap.unicode());

This toy example will print a Data Matrix using Unicode block characters. For guidance on how to generate other output formats see the helper functions defined for the Bitmap struct, or the examples/ directory of this project.

You can specify other symbol sizes, see SymbolSize for details.

Character encoding notes for Data Matrix

TL;DR Data should be printable ASCII because many decoders lack a proper charset handling. Latin 1 is the next best choice, otherwise you rely on auto detection hacks of decoders. This does not apply if you have control over decoding or if you are not overly paranoidal.

This full section also applies to QR codes.

Be careful when encoding strings which contain non printable ASCII characters. While indicating for example UTF-8 encoding is possible through ECI, we doubt that many decoders around the world implement this. Also notice that some decoders are used as a keyboard source (e.g., handheld scanners) which may be constrained by platform/locale specific keyboard layouts with limited Unicode input capabilities. We therefore recommend to stay within the printable ASCII characters unless you have control over the full encoding and decoding process.

The Data Matrix specification defines ISO 8859-1 (Latin 1) as the standard charset. Our tests indicate that some decoders (smartphone scanner apps) are reluctant to follow this and return binary output if there are charactes in the upper range, which is a safe choice. Unfortunately, some decoders try to guess the charset or just always assume UTF-8.

To forestall your question: The full 8bit range can be encoded and the decoder will also return this exact input. So the problems mentioned above are related to the interpretation of the data and possible input limitations in the case of handheld scanners.

Current limitations

No visual detection is currently implemented, but the decoding backend is done and exposed in the API. All that is missing is a detector to extract a matrix of true and false values from an image. A general purpose detector is planned for the future, though.

Other limitations: Currently there is no support for GS1, FCN1 characters, macro characters, ECI, structured append, and reader programming. The decoding output format specified in ISO/IEC 15424 is also not implemented (metadata, ECI, etc.), if you have a use case for this let us know.

Modules

data

Data part de- and encoding.

errorcode

Reed-Solomon error correction codes.

placement

Arrangement of bits in a Data Matrix symbol.

Enums

SymbolSize

The symbol sizes supported by Data Matrix.

Functions

encode

Encode data as a Data Matrix (ECC200).