Skip to content
barcoder

Standards/han-xin-code

Han Xin Code

Type2D Matrix
PrimaryCN
Completeness70%high

Overview

Han Xin Code (汉信码), also called Chinese Sensible Code, is a square two-dimensional matrix barcode from China. It was built to carry Chinese text compactly: besides digits, text and raw bytes, it has four modes that encode characters of the Chinese national character set GB 18030 directly, at 12 to 21 bits per character 28. It was developed under the Article Numbering Center of China (中国物品编码中心, ANCC, GS1 China), published as the national standard GB/T 21049 in 2007, issued by AIM as an International Symbology Specification in 2011, and published as the international standard ISO/IEC 20830 in August 2021 123.

A symbol is read like a QR Code: a camera or image scanner finds the four corner finder patterns and decodes the grid. In practice the reader has to support Han Xin, and many scanners ship with it switched off; Socket Mobile, for example, documents a configuration barcode that enables it 18. Symbols run from 23 × 23 modules (version 1) to 189 × 189 modules (version 84), and the largest holds 7,827 digits, 4,350 text characters or 3,261 bytes 23.

History

Research (2003–2005). According to a 2014 report in People's Daily's Minsheng Weekly, ANCC had studied 2D codes since 1993 and had written national standards for PDF417 and QR Code. To meet domestic demand for representing Chinese characters, it applied in 2003 for a research project on a new 2D symbology, which passed national acceptance in December 2005 6. Wikipedia describes the work as a home-grown replacement for QR Code, which was seen as a Japanese monopoly 2.

National standard (2007). The symbology was published in 2007 as GB/T 21049-2007, under the name 汉信码 / "Chinese-sensible code" 25.

AIM specification (2011). AIM put the specification out for public review in May 2011 and released it as an International Symbology Specification in September 2011. Supply Chain Digest reported it on 22 September 2011, said the symbology had been developed by AIM China, and quoted AIM board chairman Chuck Evanhoe saying it "has already been deployed in a variety of applications within China" 3. AIM's store sells revision 3.0 of the ISS, dated March 2015 4. Seagull Scientific and Aspose refer to the AIM document as AIMD-015 1719.

Public tools (2013). On 16 December 2013 ANCC released free PC encoding software and a free phone reader app, which Minsheng Weekly described as taking Han Xin from industry use to the general public. The same article said the reader maker Newland planned a Han Xin decoder chip for 2014 6.

ISO/IEC 20830 (2015–2021). ISO's project record shows the new work item approved in ISO/IEC JTC 1/SC 31 on 4 September 2015, a committee draft registered in October 2018, the draft international standard balloted from October to December 2019, the final draft balloted from June to July 2021, and publication on 27 August 2021 as edition 1, 196 pages 1.

GB/T 21049-2022. The national standard was revised as GB/T 21049-2022, published on 9 March 2022 and in force from 1 October 2022. Its title changed to 汉信码 / "Han Xin code", and the revision added Unicode, GS1 and URI modes, colour inversion, a data-transfer chapter with the ECI and GS1 protocols, and symbology identifiers 5.

Patents. Fujian Landi Commercial Equipment holds patents on detecting Han Xin finder patterns and on block decoding, including EP3330887B1 (granted 1 May 2019), US10095903B2 (granted 9 October 2018) and US10528781B2 (granted 7 January 2020) 202122. Minsheng Weekly described Han Xin itself as free of intellectual-property charges 6.

Technical specification

ISO/IEC 20830, GB/T 21049 and the AIM ISS are paid documents 145. The details below come from the Wikipedia article, which cites the ISO text by clause, from the GB/T 21049-2022 table of contents, and from open-source encoders written to the specification (Zint, BWIPP); where only an implementation states a detail, the text says so.

Scope. ISO/IEC 20830 specifies the symbology's characteristics, data encoding, symbol structure, dimensions and print quality, error-correction rules, a reference decoding algorithm and user-selectable application parameters 1.

Structure. A Han Xin symbol is square; there are no rectangular versions 2. It has four position detection (finder) patterns, one in each corner, made of nested squares with a 1:1:1:1:3 (or 3:1:1:1:1) module ratio across the pattern, unlike QR Code's 1:1:3:1:1 2. Seagull Scientific describes them as chevron-shaped 17. From version 4, alignment patterns of stepped lines cross the symbol 217. Structural (function) information next to the finders carries the version, error-correction level and mask, protected by its own Reed–Solomon code 2. Seagull gives the quiet zone as at least 3 modules 17.

Versions. 84 versions, size = 23 + 2 × (version − 1) modules: version 1 is 23 × 23, version 2 is 25 × 25, version 84 is 189 × 189 28.

Error correction. Reed–Solomon over GF(2⁸) with the field polynomial 101100011 in binary (355), that is x⁸ + x⁶ + x⁵ + x + 1, and initial root 1, at four levels. Wikipedia's text drops the final + 1 from the written polynomial, but its binary value includes it 2:

Level Recovery (approx.) Indicator bits
L1 8% 00
L2 15% 01
L3 23% 10
L4 30% 11

Masking. Four mask patterns are applied to the data region; encoders choose the best one automatically or accept a fixed one (Zint masks 0–3, BWIPP masks 1–4) 2812.

Capacity. Selected versions, from Wikipedia's table 2:

Version Level Data codewords Numeric Text Bytes Chinese characters
1 (23 × 23) L1 21 45 26 18 6–12
1 (23 × 23) L4 9 15 10 6 2–4
22 (65 × 65) L1 354 843 470 351 113–234
84 (189 × 189) L1 3,264 7,827 4,350 3,261 1,044–2,174
84 (189 × 189) L4 1,554 3,723 2,070 1,551 497–1,034

AIM's 2011 announcement splits the Chinese maximum by mode: 2,174 characters in Region One or Two, 1,739 in the 2-byte mode and 1,044 in the 4-byte mode 3. Zint's manual gives "up to 2175 Chinese characters", one more than AIM and Wikipedia 8.

Encoding modes. Modes can be mixed within one symbol 317. Wikipedia lists them with the ISO clause numbers 2:

Mode Indicator Bits per character Covers
Numeric 0001 10 bits per 3 digits 0–9
Text 0010 6 ISO/IEC 646 characters, in two submodes
Binary byte 0011 8 any byte 0–255
Common Chinese Region One 0100 12 4,074 GB 18030 characters: first byte B0–D7 with second byte A1–FE (3,760), first byte A1–A3 (282), A8A1–A8C0 (32)
Common Chinese Region Two 0101 12 3,008 characters: first byte D8–F7, second byte A1–FE
GB 18030 2-byte 0110 15 23,940 characters: first byte 81–FE, second byte 40–7E or 80–FE
GB 18030 4-byte 0111 21 1,587,600 four-byte GB 18030 characters
ECI 1000 variable switches the character set of what follows
Unicode 1001 adaptive UTF-8 with built-in lossless compression
GS1 11100001 variable GS1 Application Identifier data
URI 11100010 2–7 URIs, with the URI-A/B/C character sets

Region One is GB 2312's level-1 hanzi block plus its symbol rows, and Region Two is its level-2 block; Zint's encoder tests exactly these byte ranges 9. In numeric mode a 10-bit terminator ends the run; Wikipedia's example encodes 12700402 as 0001, three 10-bit groups and the terminator 1111111110 2. In BWIPP's encoder the terminator also says whether the last group has 1, 2 or 3 digits (1111111101, 1111111110 or 1111111111; a reading of the encoder source, not of the spec).

Default character set. Byte-mode data is read as ISO/IEC 8859-1 (Latin-1) unless an ECI says otherwise; other code pages, such as GB 18030 (ECI 000032), need an ECI 12. Zint uses Latin-1 by default and switches to GB 18030 for characters outside it, and it encodes ECIs as 4-bit mode 1000 followed by 8, 16 or 24 bits of ECI number 89. Chinese characters in the four Chinese modes need no ECI, since those modes are defined in terms of GB 18030 2.

Use cases

Han Xin is used mainly in China 2. Published, named deployments are few, and most date from ANCC's promotion in the early 2010s:

  • Newborn screening. From 2008 Han Xin labels identified newborn blood samples in disease screening in Beijing, Heilongjiang and other provinces; by early 2014 more than one million samples had been tracked this way. A supplier, Beijing Huayi Hexin, told Minsheng Weekly that sample handling became three times faster 6.
  • Medicine, food traceability and documents. The same article said Han Xin was in large-scale use in medical care, food traceability and the management of forms and bills, without naming systems 6.
  • Printing. Socket Mobile names the printing industry as the typical user 18. Label software supports it: Seagull's BarTender documents the symbology, and Aspose.BarCode for .NET exposes its version, ECI, Unicode and URI modes 1719.
  • Small-part marking (in development). ANCC has developed Han Xin Micro Code (汉信微码) for marking semiconductor devices and other tiny surfaces. Science and Technology Daily reported in June 2026 that it encodes a dozen to a hundred or so digits and letters in a few square millimetres, and that ANCC claims it outperforms Data Matrix and QR Code in density and damage resistance (an ANCC claim, not independently tested) 7.

No published case was found of Han Xin in Chinese mobile payments, which run on QR Code.

Implementations

Library Language Stars Last active Han Xin support
metafloor/bwip-js JavaScript 2,431 Aug 2026 Write, as hanxin; wraps BWIPP 14
zint/zint C 827 Oct 2026 Write, since 2.5 (Nov 2016); BARCODE_HANXIN (116); ECI, GB 18030, --fullmultibyte; library BSD-3, CLI/GUI GPLv3 81011
bwipp/postscriptbarcode PostScript 504 Oct 2026 Write, since 20 April 2016 1213
benjamin-shi/AIMHanXinCode.Net Visual Basic (.NET) 12 May 2019 Write; implements GB/T 21049 and the AIM ISS; calls itself the first open-source Han Xin project 15

Star counts were read from the GitHub API on 7 November 2026.

Encoder history. Zint fixed its use of GB 2312 instead of GB 18030 in 2.8.0 (April 2020), and in 2.11.0 (May 2022) began using the Hanzi modes when a compatible ECI is given and warning when it converts input to GB 18030 without one 10. BWIPP added GS1 mode and numeric compaction on 5 May 2026. On 20 October 2026 it began choosing the shortest mix of numeric, text, byte and Chinese modes, and ECI support is in its unreleased changes 13. The BWIPP builds that bwip-js shipped before then (bwip-js 4.11.4, August 2026, is the latest) therefore encode only numeric and byte modes (a local check of bwip-js 4.11.0, below).

Decoders. No maintained open-source Han Xin decoder was found. ZXing-C++, the main open-source reader, does not list Han Xin among its formats 16, and this site's own decoding engine cannot read it either. Reading is done by commercial SDKs and scanners, which often ship with the symbology disabled 18.

About the Try-it encoder. The panel on this page renders with bwip-js's hanxin encoder, data Han Xin 汉信码, default options. The Chinese part of that sample does not carry its meaning reliably:

  • bwip-js turns any string containing characters at U+0080 or above into UTF-8 bytes before encoding, unless the binarytext flag says the text is already 8-bit 14.
  • The bwip-js copy the wiki uses (4.11.0) has the pre-October BWIPP encoder. A local debugbits run shows a single byte-mode segment (0011, count 17) holding 48 61 6E 20 58 69 6E 20 E6 B1 89 E4 BF A1 E7 A0 81: "Han Xin " and then the UTF-8 bytes of 汉信码. There is no ECI, and none of the Chinese modes is used. The symbol is version 2 (25 × 25) at the default level L2.
  • With no ECI, a reader that follows the spec's default reads those bytes as Latin-1 and shows Han Xin æ±ä¿¡ç plus three invisible control or space characters 12. Only a reader that guesses UTF-8 shows 汉信码. The same build stops with "Unknown function character" if ^ECI000026 is sent with parsefnc, so an ECI cannot be added yet (local check).
  • Nothing here could test the result: there is no open-source Han Xin decoder to read it back.

The Latin part, Han Xin , decodes as expected under any reading. A sample that shows the Chinese modes properly would pass 汉信码 as GB 18030 bytes (BA BA D0 C5 C2 EB, all in Region One) through an encoder that has the Chinese modes; BWIPP's October 2026 encoder compacts such byte pairs into those modes 1213.

Comparison

  • vs QR Code. Both are square matrix codes with Reed–Solomon error correction, but the finder patterns differ (four corners at 1:1:1:1:3 against QR's three at 1:1:3:1:1), so a QR-only reader cannot read Han Xin 2. QR Code's double-byte mode is for Shift JIS kanji 8. A common Chinese character in Han Xin Region One or Two takes 12 bits 2, while the same character sent as UTF-8 in byte mode takes 3 bytes, 24 bits (a property of UTF-8). Han Xin is also bigger: version 84 holds 3,261 bytes 2. QR Code wins on reader support: phones, payment apps and open-source libraries read it, and Han Xin needs a specific reader 1618.
  • vs Grid Matrix. Grid Matrix is the other Chinese-optimised matrix code; Zint treats GB 2312 as its default character set, whereas Han Xin defaults to Latin-1 and reaches all of GB 18030 8. Han Xin is the one with an ISO standard 1.
  • vs Data Matrix. For marking very small parts, ANCC is developing Han Xin Micro Code rather than using Han Xin itself, and positions it against Data Matrix and QR Code 7.

Han Xin makes sense where the data is mostly Chinese text, the reader fleet is controlled and can be configured, and a Chinese standard is preferred. For codes the public scans with phones, QR Code is the safer choice.

Fun facts

  • Supply Chain Digest's 2011 headline said the code was "Named for Ancient Military Leader": Han Xin was a general who helped found the Han dynasty around 200 BC 3.
  • The GB 18030 4-byte mode alone can address 1,587,600 characters 2.

Status

Active. ISO/IEC 20830:2021 is published and has been under its five-year systematic review since 15 July 2026 1. In parallel, ANCC presented Han Xin Micro Code at the 61st meeting of SC 31's Working Group 1 in April 2026. The meeting resolved to push for its standardisation, and a revision of ISO/IEC 20830 began at the end of May 2026, planned to take about two years, to add Han Xin Micro Code to the standard 7. In China, GB/T 21049-2022 is the current national standard, and GB/T 21049-2007 is obsolete 5. Encoder work continues: BWIPP's Han Xin encoder gained Chinese-mode optimisation in October 2026 13.

Sources

Deployments

No country reports mention this standard by name.

source · content/standards/han-xin-code/index.md