GS1-128¶
GS1-128 is Code 128 with the FNC1 character first, which tells readers the data is GS1. It is the linear barcode of logistics labels: SSCCs on pallets and cartons, plus batch, dates, weights and quantities.
val message = Gs1Message.parse("(00)106141411234567897(02)09501101020917(37)24")
val symbol = Gs1Code128.encode(message)
symbol.humanReadable // (00)106141411234567897(02)09501101020917(37)24
symbol.dataCharacterCount // characters used, out of Gs1Code128.MAX_DATA_CHARACTERS (48)
symbol.widths // bar and space widths in modules, starting with a bar
How it is encoded¶
The encoder starts with FNC1 and switches between Code 128 set C (two digits per character) and set B (letters and symbols) to use as few characters as possible. A separator (FNC1) follows every variable-length value except the last one; element order keeps those to a minimum.
Limits¶
GS1 allows at most 48 data characters per symbol and a length of 165.10 mm including quiet zones.
Longer data throws Gs1Exception with Gs1ErrorCode.GS1_128_TOO_LONG. Split the data over two symbols, or use
GS1 DataMatrix. If you know what you are doing, Gs1Code128.encode(message, enforceMaxDataCharacters = false)
skips the check.
Size¶
The symbol is symbol.moduleCount modules wide plus a quiet zone of 10 modules on each side. For a given module
width (the X-dimension):
symbol.widthMm(xDimensionMm = 0.495) // total width, quiet zones included
symbol.maxXDimensionMm() // widest X that keeps the symbol within 165.10 mm
See SVG and printing for drawing it at an exact size.