1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! Code 16K (BS EN 12323:2005): a stacked symbology built on the Code 128 character
//! set, holding 2 to 16 rows of five symbol characters each.
//!
//! Layout:
//! - `tables` — the Code 128 symbol patterns and the Code 16K row start/stop
//! delimiters and row-number lookup tables.
//! - `encode` — [`Symbol`] -> [`BitMatrix`], plus the fresh-input `build` path.
//! - `decode` — [`BitMatrix`] -> [`Symbol`].
//!
//! ## Symbol structure
//!
//! Each of the `rows` stacked rows is 70 modules wide: a four-element start delimiter,
//! a one-module guard bar, five Code 128 symbol characters (11 modules each), and a
//! four-element stop delimiter. The start/stop delimiters are chosen from an eight-entry
//! table by the row number (EN 12323 Table 5), so a decoder can recover each row's
//! position. The first symbol character of the whole symbol is a mode/row-count
//! character `7*(rows-2)+m`, where `m` selects the initial Code 128 code set; the last
//! two symbol characters are the two modulo-107 check characters.
//!
//! ## Lossless round-trip
//!
//! [`Code16kMeta`] stores the exact symbol-value sequence (mode character, data and
//! padding — the two derived check characters are recomputed on render). Re-encoding
//! renders straight from that sequence, so `encode(decode(x)) == x` regardless of how
//! the payload could otherwise have been encoded. The payload [`Segment`]s carried
//! alongside are the decoded bytes and are not consulted when re-encoding.
//!
//! ## Deviations
//!
//! The fresh-input planner ([`Code16kEncoder::build`]) uses Code 128 sets A and B only
//! (no Code C numeric compression) and supports bytes `0..=127`; the decoder handles
//! Code C, FNC1/GS1 and shifts so it can also read symbols that use them.
//!
//! [`Symbol`]: crate::Symbol
//! [`BitMatrix`]: crate::output::BitMatrix
//! [`Segment`]: crate::Segment
pub use Code16kDecoder;
pub use Code16kEncoder;
/// Parameters required to re-encode a Code 16K symbol identically (lossless round-trip).
///
/// [`Code16kMeta::values`] is the exact symbol-value sequence — the mode/row-count
/// character (index 0) followed by every data and padding value — of length
/// `rows*5 - 2`. The two modulo-107 check characters are derived on encode and are
/// **not** stored here.