Expand description
This crate implements encoding and decoding of Code 128 linear barcodes as defined in ISO/IEC 15417:2007.
To achieve a minimal encoding size a dynamic programming approach is used. The full 256 bit range can be encoded. For compatibility it is recommended to stay within printable ASCII though.
Example
use code128::{Code128, modules_to_blocks};
let code = Code128::encode(b"Hello!");
println!("{}", modules_to_blocks(code.modules()));To create other outputs check out the Code128 documentation.
Charsets
For best compatibility it is recommended to only encode printable
ASCII
characters, i.e. 0x20 (space) to 0x7E (tilde).
Code 128 interprets the range 0x00 to 0x7F as ASCII, and 0xA0 to
0xFF as ISO/IEC 8859-1
(Latin 1). The remaining range from 0x80 to 0x9F can also be encoded
but has no visual representation.
In the real world most implementations only handle 0x00 to 0x7F, or
interpret results as UTF-8, although that is not covered by the standard.
However, if you are in control of encoding and decoding this is technically
possible and maybe even a contemporary choice.
Structs
- A Code 128.
- Representation of a “black line” in the code.
Enums
- Errors that can occur during decoding.
Functions
- Decode a sequence of modules.
- Decode the modules and interpret the data as Latin 1.
- Create a string representation of the modules using Unicode block characters.