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
| Item | Value |
|---|---|
| Type token | HANXIN |
| Enum case | BarcodeType::HANXIN |
| Family | 2D |
| Standard | GB/T 21049, ISO/IEC 20830 |
| Class | \Com\Tecnick\Barcode\Type\Square\HanXin |
Input
| Item | Value |
|---|---|
| Character set | any byte sequence, with a dedicated mode for GB 18030 text |
| Length | up to 7827 digits or 4350 bytes |
| Check | Reed-Solomon error correction at the chosen level |
| Extra parameters | 3 (see below) |
Extra Parameters
Appended to the type token after commas, as in HANXIN,L3,10,2.
| Position | Meaning | Values | Default |
|---|---|---|---|
| 1 | error correction level | L1, L2, L3, L4 | L1 |
| 2 | version | 0 for automatic, or 1 to 84 | 0 |
| 3 | mask | 0 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();
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');
Errors
These payloads raise \Com\Tecnick\Barcode\Exception:
| Payload | Message |
|---|---|
| `` | Empty input |
See Also
- tc-lib-barcode : the library overview.
- Rendering Options : size, colour, padding.
- Output Formats : every renderer.
- QR Code : the format it is most often compared with.
- API reference : the generated class documentation.