Code 128 barcode encoder.
Encodes a string into a list of bar widths suitable for rendering. Supports Code 128B (full ASCII) with automatic Code C optimization for runs of digit pairs.
Reference
Code 128 uses three character sets (A, B, C). This implementation primarily uses Code B (covers ASCII 32–127) with automatic switching to Code C for efficient encoding of digit pairs.
Summary
Functions
Encode a string into Code 128 bar pattern.
Returns {:ok, bars} where bars is a flat list of integers
representing alternating bar and space widths (starting with a bar).
Returns {:error, reason} if the input contains unsupported characters.
Same as encode/1 but raises on error.
Calculate the total width in modules (unit bar widths) for a given text.