CODE 39 Extended

Extended CODE 39 barcode in PHP: full ASCII encoding, input range, code example and SVG output

Plain CODE 39 reaches 43 characters. The extended form covers all 128 ASCII values by encoding anything outside those 43 as a pair, with $, %, / and + acting as shift characters.

Lower case and control characters therefore cost two CODE 39 characters each, and a symbol carrying mixed-case text comes out close to twice the width of the same text in upper case.

Type Token

ItemValue
Type tokenC39E
Enum caseBarcodeType::C39E
FamilyLinear
StandardANSI MH10.8M-1983, USD-3
Class\Com\Tecnick\Barcode\Type\Linear\CodeThreeNineExt

Input

ItemValue
Character setthe 128 ASCII characters
Length1 to 30000 characters
Checknone. Use C39E+ for the modulo 43 check character
Extra parametersnone

Examples

Digits

<?php

require_once __DIR__ . '/vendor/autoload.php';

$barcode = new \Com\Tecnick\Barcode\Barcode();
$bobj = $barcode->getBarcodeObj(
    type: 'C39E',
    code: '0123456789',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

echo $bobj->getInlineSvgCode();

CODE 39 Extended barcode encoding 0123456789

Mixed case, reached through the shift pairs

$bobj = $barcode->getBarcodeObj(
    type: 'C39E',
    code: 'tc-lib-barcode',
    width: -3,
    height: -30,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

CODE 39 Extended barcode encoding tc-lib-barcode

Errors

These payloads raise \Com\Tecnick\Barcode\Exception:

PayloadMessage
caf\xC3\xA9Invalid character: 195

See Also