Code 128
Code 128 is a high-density linear barcode symbology that encodes the full 128-character ASCII set, including uppercase and lowercase letters, digits, symbols, and control codes, making it suitable for compact representation of alphanumeric data.[1] Developed in 1981 by Ted Williams at Computer Identics Corporation, it was designed to provide efficient encoding for industrial and commercial applications.[2] The standard is formally defined in ISO/IEC 15417:2007, which specifies its bar and space patterns, data encodation rules, dimensions, decoding algorithms, and application parameters.[3] Code 128 operates through three character subsets to achieve versatility and density: Subset A encodes uppercase letters (A–Z), digits (0–9), and control characters (00–31 plus DEL); Subset B extends this to include lowercase letters (a–z) alongside uppercase, digits, and common symbols; while Subset C enables high-efficiency numeric encoding by pairing two digits per codeword (00–99).[4] Barcodes begin with a start character selecting the initial subset, include a modulo-103 check digit for error detection, and end with a stop pattern, allowing seamless switches between subsets for optimal data compression within variable-length symbols.[5] This structure supports quiet zones on either side for reliable scanning and uses variable bar widths to balance density with readability. Widely adopted in supply chain and logistics, Code 128 serves as the foundation for GS1-128, which incorporates application identifiers to encode structured data like serial numbers, batch codes, and expiration dates in up to 48 characters.[6] Common applications include shipping labels, inventory tracking, healthcare product labeling under ISBT 128, and USPS mail processing, where its alphanumeric capability and compactness outperform fixed-length symbologies like UPC.[7][8] The symbology's flexibility has made it a preferred choice for non-retail environments, with ongoing support in modern scanning technologies despite the rise of 2D barcodes.[9]History and Development
Origins and Invention
Code 128, a high-density linear barcode symbology, was developed in 1981 by the Computer Identics Corporation, a U.S.-based firm specializing in automatic identification technologies for industrial use.[10] The creation addressed growing demands in logistics and inventory management for a more efficient method to encode alphanumeric data compactly, enabling faster and more reliable data capture in supply chain operations.[11] Computer Identics, founded earlier by David Collins as a pioneer in barcode systems, recognized the need for advancements beyond existing technologies to support expanding industrial automation.[12] The primary inventor was Ted Williams, an engineer at Computer Identics, who designed Code 128 to encode the full 128-character ASCII set while maintaining a smaller footprint than predecessors.[2] This innovation stemmed from the limitations of Code 39, the dominant symbology at the time, which offered lower data density and supported only uppercase letters, numbers, and a few symbols, making it inadequate for complex alphanumeric tracking in manufacturing and distribution.[13] Williams' approach emphasized variable-width bars and modular encoding to achieve higher information density without sacrificing readability by standard laser scanners.[10] Early implementation involved prototyping the symbology for real-world industrial testing, particularly in manufacturing environments where compact labeling was essential for inventory control and parts identification during the mid-1980s.[14] These initial trials demonstrated Code 128's superior performance in high-volume production settings, paving the way for its broader integration into automated systems. Subsequent efforts led to formal standardization, enhancing its role in global supply chains.[2]Standardization and Adoption
Code 128 was formally adopted as a public domain standard by the Association for Automatic Identification and Mobility (AIM) through its Uniform Symbology Specification (USS) for Code 128, establishing consistent guidelines for its implementation across industries.[15] This endorsement facilitated interoperability among barcode readers and printers, promoting its use beyond proprietary systems.[2] In 2000, the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC) incorporated Code 128 into the ISO/IEC 15417 standard, which detailed its symbology characteristics, data character encoding methods, dimensions, and requirements for compliance to ensure global uniformity.[16] This international ratification solidified Code 128's specifications for worldwide applications, including alphanumeric and numeric data encoding in logistics and inventory management.[3] By the late 1980s, advancements in hardware, particularly the commercialization of laser scanners capable of reliably reading high-density symbologies like Code 128, accelerated its practical deployment in supply chains.[17] These devices, introduced in 1969 and widely available by the 1970s, reduced reading errors and increased scanning speeds compared to earlier light-based systems, enabling efficient data capture in dynamic environments such as warehouses.[18] Widespread adoption occurred through integration into GS1 systems (formerly the Uniform Code Council [UCC] and European Article Number [EAN]) by the early 1990s, particularly for shipping labels and retail cartons to encode variable data like lot numbers and expiration dates.[2] In 1988, UCC and EAN International endorsed Code 128—rebranded as UCC/EAN-128—for despatch units, marking a pivotal step in standardizing supplementary information in global trade.[5] This timeline transformed supply chain operations by supporting accurate tracking and reducing manual errors, with GS1's Application Identifiers further enhancing data structure interpretation starting in 1989.[2]Overview and Design Principles
Key Features and Advantages
Code 128 is a variable-length, high-density linear barcode symbology capable of encoding the full 128-character ASCII set, including alphanumeric characters, numeric digits, and control codes.[19] This versatility allows it to represent a wide range of data types in a compact form, making it suitable for applications requiring efficient space utilization.[20] One of the primary advantages of Code 128 is its superior data density compared to earlier symbologies like Code 39, enabling more compact encoding for alphanumeric data while supporting higher character capacities per unit length.[21] It incorporates a mandatory self-checking mechanism via a modulo 103 checksum, which enhances error detection during scanning.[22] Additionally, Code 128 supports bidirectional scanning, allowing readers to decode the symbol from either direction, which improves operational flexibility in logistics and inventory systems.[23] The design of Code 128 prioritizes compact representation of structured data such as serial numbers, dates, and unique identifiers, particularly in environments with limited label space.[24] It includes three subtypes—A for control characters and uppercase letters, B for full ASCII, and C for double-density numerics—to optimize encoding for specialized uses.[11] Despite these strengths, Code 128 has limitations, including the need for precise printing to avoid decoding errors due to its high-density structure, which demands high-resolution printers and scanners.[13] The symbology itself is not human-readable without the application of specialized barcode fonts that interpret the bars as text.[25]Comparison to Other Symbologies
Code 128 offers higher data density than Code 39, encoding data with fewer bars per character, which allows for more compact symbols in space-limited applications such as shipping labels.[21] Unlike Code 39, which supports only 43 standard characters (with extended versions requiring multiple symbols for full ASCII), Code 128 natively encodes all 128 ASCII characters, enabling richer data representation like special symbols and control codes.[21] However, this increased efficiency comes at the cost of greater decoding complexity for Code 128, as its variable-length codewords demand more sophisticated scanner algorithms compared to the fixed-width patterns of Code 39.[21] In comparison to Code 93, Code 128 offers higher density for alphanumeric encoding but incorporates more advanced control functions, including function codes (FNC1–FNC4) that facilitate structured data in logistics and support for GS1 application identifiers.[26][27] Code 93 is an alphanumeric symbology with a standard set of 47 characters (uppercase letters, digits, and symbols), extendable to full ASCII, and features a simpler encoding scheme with two check digits for error detection, making it suitable for basic inventory tasks but less versatile for complex messaging.[28][29] Relative to 2D symbologies like Data Matrix, Code 128 remains a linear barcode that enables faster scanning with traditional line-of-sight readers, ideal for high-speed conveyor environments in warehouses.[30] However, it stores far less data—typically up to a few hundred characters in a linear format—compared to Data Matrix, which can encode thousands of characters in a compact square pattern, better suiting applications requiring extensive information like serial numbers and compliance data.[31] Code 128 plays an evolutionary role in bridging traditional 1D linear codes to modern hybrid systems in logistics, where its high density and extensibility via GS1-128 standards support seamless integration with emerging 2D and digital tracking technologies.[32]Technical Specifications
Subtypes (A, B, and C)
Code 128 employs three distinct subtypes—Code Set A, Code Set B, and Code Set C—to accommodate varying data requirements while maintaining high encoding density. Each subtype corresponds to a specific subset of the ASCII character set, selected via a start character that initiates the symbol in that mode.[9] Switching between subtypes during encoding is facilitated by dedicated code set selection characters, enabling a single symbol to handle mixed alphanumeric and numeric data efficiently.[25] Code Set A supports the ASCII range from 0 to 95, including uppercase letters (A–Z), digits (0–9), standard punctuation, and 32 control characters (00–31, such as NUL and SOH), along with function characters FNC1–FNC4. In Code Set A, code values 0–94 encode ASCII 0–94 (control codes to uppercase and symbols). This subtype is particularly suited for legacy systems interfacing with older equipment that relies on control codes for data transmission and formatting.[33][34] Code Set B encompasses the full printable ASCII character set from 32 to 127, incorporating uppercase and lowercase letters (A–Z, a–z), digits (0–9), and all standard printable symbols and punctuation. In Code Set B, code values 0–94 encode ASCII 32–126 (printable characters), and 95 encodes DEL (127). It is optimal for applications involving text-heavy content, such as product descriptions, shipping labels, or any scenario requiring the complete range of human-readable alphanumeric data without control codes.[9][33] Code Set C is dedicated to numeric-only encoding, representing pairs of digits (00–99) within each code character to achieve the highest possible density for pure numerical strings. In Code Set C, code values 0–99 encode digit pairs 00–99. This makes it ideal for encoding long sequences of numbers, such as serial numbers, batch codes, or quantities in inventory systems, where space efficiency is paramount.[9][35]Character Set and Encoding
Code 128 utilizes a set of 106 distinct code words, indexed from 0 to 105, where each code word is represented by a unique pattern of bars and spaces to encode data efficiently. Code values 0–95 generally correspond to data characters (alphanumeric, control, or numeric pairs depending on the set), while specific values within this range (e.g., 96–102, 98–101) are designated for function characters FNC1 through FNC4, which enable special operations such as linking symbols or reader initialization, and for code set selection, allowing transitions between subsets A, B, C, and a temporary shift mode. This structure supports the encoding of all 128 ASCII characters across the subsets, with the patterns remaining consistent regardless of the active subset.[3][11] The core of the encoding scheme is an encoding table that assigns each code word to a precise 11-module pattern comprising three bars and three spaces, ensuring high density and readability. A module is defined as the narrowest bar or space width in the symbol, serving as the fundamental unit of measure; all elements are integer multiples of one to four modules, with the total width per character fixed at 11 modules to maintain uniform scanning. For instance, code word 33 maps to the exclamation mark (!) in Code Set A with its unique 11-module pattern of three bars and three spaces. Similar unique patterns apply to all code words, with no two sharing the same bar-space sequence to prevent decoding ambiguity.[36] To achieve full ASCII coverage, Code 128 incorporates shift mechanisms that temporarily switch between code sets without altering the overall subtype, enabling access to extended characters like lowercase letters or additional symbols. For example, a shift code (code word 98 in Sets A or B) allows encoding of characters from the alternate set for a single position, reverting automatically, while FNC4 (code word 100 in Set A or 101 in Set B) supports extension to Latin-1 characters beyond standard ASCII. This approach ensures compact representation of diverse data without requiring multiple symbols or subtype changes.[3][27]Start, Stop, and Shift Mechanisms
Code 128 employs distinct start patterns to initiate the barcode symbol and select the initial character encoding set, ensuring scanner synchronization from the outset. There are three start variants, each comprising an 11-module pattern of three bars and three spaces with widths ranging from 1 to 4 modules. The Start A pattern (for code set A, encoding control characters and uppercase letters) follows the sequence bar (2 modules)-space (1)-bar (1)-space (4)-bar (1)-space (2). Start B (for code set B, encoding full ASCII printable characters) uses bar (2)-space (1)-bar (1)-space (2)-bar (1)-space (4). Start C (for code set C, encoding pairs of digits for compact numeric data) is bar (2)-space (1)-bar (1)-space (2)-bar (3)-space (2). These patterns precede the first data character and establish the module width reference for the entire symbol.[37] The stop pattern serves as a universal terminator for all Code 128 symbols, spanning 13 modules with four bars and three spaces to signal the conclusion of the data, including the mandatory check character. Its sequence is bar (2)-space (3)-bar (3)-space (1)-bar (1)-space (1)-bar (2), designed to support bidirectional scanning by producing a unique reverse pattern that the decoder recognizes as invalid when read backward. A trailing quiet zone of at least 10 modules (typically 0.25 inches or 6.4 mm) must follow the stop pattern to isolate the symbol and prevent interference from adjacent elements or media edges.[9] Shift and latch mechanisms facilitate dynamic transitions between the A, B, and C code sets within a single symbol, optimizing encoding for mixed alphanumeric and numeric content without requiring multiple start patterns. The shift function, invoked by code value 98 (pattern: bar (4)-space (1)-bar (1)-space (3)-bar (1)-space (1)), temporarily alters the code set for only the immediately following character before reverting to the prior set; this is particularly useful for isolated characters from another set, such as a lowercase letter in a mostly uppercase string. In contrast, latch functions enable permanent changes: code 99 in sets A or B latches to set C (pattern: bar (1)-space (1)-bar (3)-space (1)-bar (4)-space (1)), code 100 in set A latches to B, and code 101 in set B latches to A. These control codes (values 98–101) are special function characters not transmitted in the decoded output but essential for set management.[38] During decoding, the start pattern calibrates the scanner's timing and module measurement while selecting the baseline code set, preventing misalignment in variable-width bars and spaces. Shift and latch patterns are interpreted inline to adjust mappings for subsequent characters, maintaining data integrity across set boundaries. The stop pattern cues the decoder to process the final check character for error validation and halt reading, with the overall mechanisms contributing to robust synchronization and fault tolerance in noisy scanning environments.Encoding Process
Data Preparation and Mapping
The data preparation phase for Code 128 encoding begins with analyzing the input data to determine the most suitable primary subset, ensuring compatibility and efficiency in representation.[3] Subset C is selected for purely numeric data to maximize density by encoding pairs of digits, subset B for alphanumeric text including uppercase and lowercase letters, and subset A for data incorporating ASCII control characters.[11] This initial analysis considers the data's composition, length, and frequency of character types to avoid unnecessary mode switches later in the process.[9] Once the primary subset is identified, the mapping process translates each input character or digit pair into a corresponding code set value from 0 to 105, as defined by the subset's character table. In subset B, for instance, the uppercase letter 'A' maps to code value 33, the digit '0' to 16, and the lowercase 'a' to 65.[39] Subset A uses similar mappings for uppercase and control characters (codes 0–31 for NUL to US), while subset C exclusively maps two-digit combinations from "00" (code 0) to "99" (code 99); for odd-length numeric strings, switch to subset A or B to encode the single digit.[40] These mappings ensure that the data is represented as a sequence of integer code values ready for further processing. To optimize the encoded sequence and minimize the resulting barcode length, the preparation incorporates strategic use of latch and shift mechanisms, grouping similar character types to reduce overhead from mode changes. Consecutive numeric segments are ideally grouped and latched into subset C to encode two digits per codeword, potentially shortening the symbol by up to 50% compared to single-digit encoding in subsets A or B.[41] For mixed data, the algorithm evaluates potential latch sequences (permanent mode switches via 103 to A, 104 to B, 105 to C) versus temporary shifts (101 to A, 100 to B, 99 to C for single-character mode change), selecting the combination that yields the fewest total codewords.[39] Code 128 accommodates variable-length data effectively, supporting up to approximately 48 characters in subsets B and C for standard applications like shipping labels, where the exact capacity depends on the proportion of mode switches and special function characters included.[11]| Subset | Example Mapping | Code Value |
|---|---|---|
| B | 'A' | 33 |
| B | '0' | 16 |
| B | 'a' | 65 |
| C | "12" | 12 |
| C | "00" | 0 |