CODE 128 covers the full ASCII set across three subsets: A for control characters and upper case, B for the printable range including lower case, C for pairs of digits at one character per two. This type picks the subsets and the switches between them from the payload, which for numeric data means roughly half the width of CODE 39.
Where the subset has to be fixed, use C128A, C128B or C128C instead.
Type Token
| Item | Value |
|---|---|
| Type token | C128 |
| Enum case | BarcodeType::C128 |
| Family | Linear |
| Standard | ISO/IEC 15417 |
| Class | \Com\Tecnick\Barcode\Type\Linear\CodeOneTwoEight |
Input
| Item | Value |
|---|---|
| Character set | the 128 ASCII characters |
| Length | 1 to 30000 characters |
| Check | modulo 103, computed by the library |
| Extra parameters | none |
Examples
Digits, which switch the encoder into subset C
<?php
require_once __DIR__ . '/vendor/autoload.php';
$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
type: 'C128',
code: '0123456789',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
echo $bobj->getInlineSvgCode();
Mixed case text
$bobj = $barcode->getBarcodeObj(
type: 'C128',
code: 'tc-lib-barcode',
width: -3,
height: -30,
color: 'black',
padding: [0, 0, 0, 0],
)->setBackgroundColor('white');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
caf\xC3\xA9 | Invalid character sequence: 195 |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- CODE 128 A : subset A only.
- CODE 128 B : subset B only.
- CODE 128 C : subset C only, digits in pairs.
- GS1-128 : CODE 128 carrying GS1 Application Identifiers.
- API reference : the generated class documentation.