Table of contents
Namespace: Com\Tecnick\Barcode\Type\Linear\GsOneDataBar
class Compaction
Source: src/Type/Linear/GsOneDataBar/Compaction.php:42
General purpose data compaction of GS1 DataBar Expanded (ISO/IEC 24724)
Turns a character sequence into a binary string with three encodation schemes: numeric, which packs a pair of digits or a digit and the Function 1 Symbol Character into 7 bits and is current at the start of the field, alphanumeric, which spends 5 or 6 bits per character, and ISO/IEC 646, which spends 5, 7 or 8 bits per character. Latch characters switch between them.
Constants
ALPHANUMERIC
Alphanumeric encodation scheme
public const ALPHANUMERIC = 1
Source: src/Type/Linear/GsOneDataBar/Compaction.php:64
CHARACTER_BITS
Number of bits of a symbol character
public const CHARACTER_BITS = 12
Source: src/Type/Linear/GsOneDataBar/Compaction.php:54
FNC1
Function 1 Symbol Character, the element string separator
public const FNC1 = "\xf1"
Source: src/Type/Linear/GsOneDataBar/Compaction.php:49
ISO646
ISO/IEC 646 encodation scheme
public const ISO646 = 2
Source: src/Type/Linear/GsOneDataBar/Compaction.php:69
NUMERIC
Numeric encodation scheme
public const NUMERIC = 0
Source: src/Type/Linear/GsOneDataBar/Compaction.php:59
Methods
encode()
Encode a character sequence into the general purpose data compaction field.
public encode(string $data, int $prefix, int $minimum, int &$mode): string
Parameters:
$data(string): Character sequence, with the Function 1 Symbol Character as separator$prefix(int): Number of bits that precede the field in the binary string$minimum(int): Smallest number of symbol characters of the symbol$mode(int): Encodation scheme in force at the end of the field
Returns: string
Throws:
- Exception: if the sequence cannot be encoded
Source: src/Type/Linear/GsOneDataBar/Compaction.php:371
getCapacity()
Get the capacity in bits of the symbol that holds the given number of bits.
public getCapacity(int $length, int $minimum): int
Parameters:
$length(int): Number of bits to hold$minimum(int): Smallest number of symbol characters of the symbol
Returns: int
Source: src/Type/Linear/GsOneDataBar/Compaction.php:418
getPadding()
Get the padding of the binary string.
The numeric scheme is left first, because its latch is the only one that a decoder does not read as data.
public getPadding(int $missing, int $mode): string
Parameters:
$missing(int): Number of bits to fill$mode(int): Encodation scheme in force at the end of the data
Returns: string
Source: src/Type/Linear/GsOneDataBar/Compaction.php:435
setCharacterCount()
Set how the symbology counts the symbol characters.
The trailing digit of the numeric scheme takes the short form only when it ends the symbol, so the count has to be the one of the symbol that is actually drawn.
public setCharacterCount(callable $charcount): void
Parameters:
$charcount(callable): Number of bits and smallest number of symbol characters to number of symbol characters