Compaction

General purpose data compaction of GS1 DataBar Expanded (ISO/IEC 24724)

Namespace: Com\Tecnick\Barcode\Type\Linear\GsOneDataBar

File: Compaction.php line 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.

Tags

Constants

ALPHANUMERIC

File: Compaction.php line 64

public mixed ALPHANUMERIC = 1

CHARACTER_BITS

File: Compaction.php line 54

public mixed CHARACTER_BITS = 12

FNC1

File: Compaction.php line 49

public string FNC1 = "\xf1"

ISO646

File: Compaction.php line 69

public mixed ISO646 = 2

NUMERIC

File: Compaction.php line 59

public mixed NUMERIC = 0

Methods

encode()

File: Compaction.php line 371

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

Tags

  • throws: Exception if the sequence cannot be encoded

Return values

string

getCapacity()

File: Compaction.php line 418

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

Return values

int

getPadding()

File: Compaction.php line 435

public getPadding(int $missing, int $mode) : string

The numeric scheme is left first, because its latch is the only one that a decoder does not read as data.

Parameters

  • $missing : int: Number of bits to fill
  • $mode : int: Encodation scheme in force at the end of the data

Return values

string

setCharacterCount()

File: Compaction.php line 406

public setCharacterCount(callable(int, int): int $charcount) : void

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.

Parameters

  • $charcount : callable(int, int): int: Number of bits and smallest number of symbol characters to number of symbol characters