Research and Application of Code 128 Barcode Encoding Rules | Abstract | Code 128 barcode, as a high-density, high-capacity barcode symbol system, is widely used in logistics, retail, manufacturing, and other fields. This paper systematically studies the encoding rules of Code 128 barcode, including core aspects such as symbol structure, character set selection, encoding method, and verification mechanism, and discusses its advantages and limitations in practical applications. Through theoretical analysis and case verification, the significant characteristics of Code 128 barcode in terms of information encoding efficiency, data reliability, and cross-industry applicability are revealed. | 
| Keywords | Code 128 barcode; encoding rules; character set; verification mechanism; application scenarios | Introduction | Barcode technology, as an important means of automatic information identification, plays an irreplaceable role in the digital age. Code 128 barcode, as a continuous, high-density barcode symbol, is widely used in global supply chain management, inventory control, product traceability, and other fields because it can encode all 128 ASCII characters. Its flexible and efficient encoding rules make it a leader among barcode technologies. This article aims to deeply analyze the encoding rules of Code 128 barcodes, providing theoretical support for research and applications in related fields. | Basic Overview of Code 128 Barcodes | Introduced by Symbol Inc. in 1981, Code 128 is a variable-length, continuous, high-density barcode symbol. Its name derives from its ability to encode 128 ASCII characters, including numbers, letters, symbols, and control characters. Code 128 barcodes consist of a start character, data characters, a check character, and a stop character. Each character is composed of 3 bars and 3 spaces, for a total module width of 11. Its design was intended to meet high-density encoding requirements while ensuring the accuracy and reliability of data recognition. | 
| Encoding Rules of Code 128 Barcodes | 1. Character Set Selection and Subset Division | The character set of Code 128 barcodes is divided into three subsets: Subset A, Subset B, and Subset C, each corresponding to a different character range. Subset A contains uppercase letters, numbers, control characters, and special symbols; Subset B contains uppercase and lowercase letters, numbers, and some special symbols; Subset C is specifically designed for numbers, using a two-character encoding method, with each character representing two digits. This subset division allows Code 128 barcodes to flexibly adapt to encoding needs in different scenarios. For example, in logistics management, Subset C can efficiently encode purely numerical information, significantly improving encoding density. | 2. Encoding Method and Module Structure | Code 128 barcode encoding is based on the correspondence between module width and character logical values. Each character consists of 3 bars and 3 spaces, for a total of 11 module widths. Module widths are divided into wide, medium, and narrow, with wide modules being 2-3 times wider than narrow modules. The logical value of a character (0-107) is represented by the module width of the bar-space combination. For example, the logical value of the character 'A' in Subset A is 32, and its bar-space combination is narrow bar-narrow space-narrow bar-narrow space-wide bar-narrow space. This encoding method ensures the stability and recognizability of the barcode symbol. | 3. Start and End Character Design | Code 128 barcodes use start characters to identify the barcode type and character set. There are three types: A start character, B start character, and C start character. The start character consists of a specific bar-space combination; for example, the A start character's bar-space combination is narrow bar-narrow space-narrow bar-narrow space-narrow bar-wide space. The end character indicates the end of the barcode, and its bar-space combination is narrow bar-narrow space-narrow bar-wide space. The design of the start and end characters ensures the integrity of the barcode symbol and the accuracy of recognition. | 4. Check Mechanism and Data Reliability | Code 128 barcodes use a check mechanism to ensure the accuracy of data recognition. The check character is obtained by calculating the sum of the logical values ??of all data characters and then taking the modulo 103. For example, the logical value of the data character 'A' in subset A is 32. If the data characters are 'A' and 'B' (logical value 33), then the check character is (32+33) mod 103 = 65. This verification mechanism effectively reduces the data misread rate and improves the reliability of barcode recognition. | 
| Advantages of Code 128 Barcode Applications | 1. High-Density Encoding Capability | The modular width design of Code 128 barcodes enables high-density encoding, with each character occupying only 11 modules. Compared to Code 39 barcodes, Code 128 barcodes can encode more information in the same length, making them suitable for space-constrained scenarios such as small product labels or high-density logistics packaging. | 2. Full Character Set Support | Code 128 barcodes support all 128 ASCII characters, including numbers, letters, symbols, and control characters. This allows them to flexibly adapt to the encoding needs of different industries and scenarios. For example, in the medical field, they can encode complex information such as drug names, batch numbers, and production dates. | 3. Cross-Industry Applicability | The flexibility and efficiency of Code 128 barcodes make them widely used in logistics, retail, manufacturing, medical, and other fields. For example, in logistics management, Code 128 barcodes can be used for package tracking and inventory management; in retail, they can be used for product labeling and price management; and in manufacturing, they can be used for product traceability and quality control. | 
| Limitations of Code 128 Barcodes | 1. High Encoding Complexity | The encoding rules of Code 128 barcodes are relatively complex, requiring the selection of a subset based on the character set and the calculation of check characters. This increases the complexity and time cost of the encoding process, especially in large-scale application scenarios, potentially affecting encoding efficiency. | 2. High Requirements for Scanning Equipment | The high-density encoding characteristics of Code 128 barcodes place high demands on the resolution and recognition capabilities of scanning equipment. Low-end scanning equipment may not be able to accurately recognize Code 128 barcodes, leading to data misreading or recognition failure. | 
| Conclusion | As a high-density, high-capacity barcode symbol system, Code 128 barcodes have significant advantages in character set selection, module structure, start and stop character design, and verification mechanisms. Its high-density encoding capability, full character set support, and cross-industry applicability make it an important tool in barcode technology. However, its high encoding complexity and demanding requirements for scanning equipment also need to be considered in practical applications. In the future, with the continuous development of barcode technology, the encoding rules of Code 128 barcodes are expected to be further optimized to meet more diverse and complex application needs. |
|