Han Xin Code

Han Xin Code in PHP: error correction levels, 84 versions, code examples and SVG output

Han Xin was designed in China for Chinese text, and encodes GB 18030 characters directly rather than through an escape mechanism. Eighty-four versions, from 23 modules square to 189, and four error correction levels from L1 to L4.

Its finder patterns differ from the QR Code ones, so a reader has to be told to look for it.

Type Token

ItemValue
Type tokenHANXIN
Enum caseBarcodeType::HANXIN
Family2D
StandardGB/T 21049, ISO/IEC 20830
Class\Com\Tecnick\Barcode\Type\Square\HanXin

Input

ItemValue
Character setany byte sequence, with a dedicated mode for GB 18030 text
Lengthup to 7827 digits or 4350 bytes
CheckReed-Solomon error correction at the chosen level
Extra parameters3 (see below)

Extra Parameters

Appended to the type token after commas, as in HANXIN,L3,10,2.

PositionMeaningValuesDefault
1error correction levelL1, L2, L3, L4L1
2version0 for automatic, or 1 to 840
3mask0 to 3, or -1 for automatic-1

Examples

Digits in the smallest symbol that fits

<?php

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

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

echo $bobj->getInlineSvgCode();

Han Xin Code barcode encoding 0123456789

Error correction level L3 at a fixed version

$bobj = $barcode->getBarcodeObj(
    type: 'HANXIN,L3,10,2',
    code: '1234567890ABCDEFGabcdefg',
    width: -4,
    height: -4,
    color: 'black',
    padding: [0, 0, 0, 0],
)->setBackgroundColor('white');

Han Xin Code barcode encoding 1234567890ABCDEFGabcdefg

Errors

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

PayloadMessage
``Empty input

See Also