Code 128 subset C (ISO/IEC 15417), the barcode the DANFE prints for the access key.
Subset C encodes two digits per symbol, so the 44 digits of an access key are 22 symbols between
a start symbol and a check symbol, followed by the stop pattern: 277 modules in all. encode/1
gives the bars as {offset, width} pairs in modules, which the layout draws as rectangles.
Summary
Functions
The check symbol: the start value plus each value times its position, modulo 103.
The bars of digits as {offset, width} in modules, from the left edge of the first bar. The
total width is modules/1.
The width of the code of digits in modules (11 * (pairs + 2) + 13).
The widths of every symbol, as the table lists them (value 0 to 106).
The symbol values of digits in subset C: start, one value per pair of digits, the check symbol
and the stop.
Types
@type bars() :: [{non_neg_integer(), pos_integer()}]
Functions
@spec checksum([0..99]) :: 0..102
The check symbol: the start value plus each value times its position, modulo 103.
The bars of digits as {offset, width} in modules, from the left edge of the first bar. The
total width is modules/1.
@spec modules(String.t()) :: pos_integer()
The width of the code of digits in modules (11 * (pairs + 2) + 13).
@spec patterns() :: [String.t()]
The widths of every symbol, as the table lists them (value 0 to 106).
@spec symbols(String.t()) :: {:ok, [0..106]} | {:error, :invalid}
The symbol values of digits in subset C: start, one value per pair of digits, the check symbol
and the stop.
{:error, :invalid} unless digits is a non-empty string of digits of even length.