Code 39
Code 39 is a discrete, variable-length barcode symbology that encodes alphanumeric data using a pattern of bars and spaces, standardized under ISO/IEC 16388 for automatic identification and data capture applications.[1] It supports a character set of 43 symbols, including the uppercase letters A–Z, digits 0–9, and five special characters (-, ., $, /, +), with an asterisk (*) serving as both start and stop delimiter for self-checking purposes.[2] Developed in the mid-1970s as the first alphanumeric barcode, Code 39 was designed for flexibility in encoding mixed data without fixed length restrictions, making it suitable for labeling and tracking in industrial environments.[2] Originally created by Intermec Corporation (then Interface Mechanisms, Inc.) in 1974–1975 to address the limitations of numeric-only barcodes, Code 39 gained formal recognition as an ANSI standard (MH10.8M-1983) in the early 1980s, enhancing its adoption across sectors.[2] The symbology's structure consists of nine elements per character—five bars and four spaces—with three wide elements and six narrow ones, allowing bidirectional scanning and inherent error detection without mandatory check digits, though an optional modulo-43 checksum can be included for added verification.[1] An extension known as Full ASCII Code 39 expands the set to 128 characters by pairing symbols to represent lowercase letters and additional punctuation, enabling broader data representation while maintaining compatibility.[3] Code 39 remains prevalent in non-retail industries, including logistics, manufacturing, healthcare, and defense, for applications like inventory control, asset tracking, and serial numbering, due to its simplicity, readability on poor-quality prints, and support by most barcode scanners.[2] Unlike GS1-managed symbologies such as UPC or EAN, which dominate retail point-of-sale, Code 39's independence from proprietary systems has ensured its longevity, though it is gradually supplemented by more efficient codes like Code 128 in high-density scenarios.[4] Its dimensions and tolerances are precisely defined in the ISO standard to guarantee reliable decoding, with typical ratios of 2:1 or 3:1 for wide-to-narrow elements, balancing density and print tolerance.[1]Introduction
Overview
Code 39 is a variable-length, discrete, alphanumeric barcode symbology standardized as ISO/IEC 16388:2023, which specifies its characteristics for encoding data in general industrial applications.[1] This symbology supports the encoding of uppercase letters (A–Z), digits (0–9), and seven special symbols: space, hyphen (-), period (.), plus (+), dollar ($), slash (/), and percent (%).[5] It employs the asterisk (*) as both start and stop characters to frame the data, ensuring proper decoding boundaries.[2] A key feature of Code 39 is its optional check digit, which can be included for error detection using a modulo-43 algorithm based on character values.[3] In basic operation, a barcode scanner interprets the pattern of wide and narrow bars and spaces—nine elements per character—to reconstruct the original alphanumeric data. As a linear one-dimensional (1D) barcode, Code 39 produces symbols of variable width proportional to the encoded message length, allowing flexibility in data capacity.[1] Code 39 finds primary use in non-retail environments, including inventory tracking, asset identification, manufacturing, logistics, defense, and healthcare applications where alphanumeric labeling is needed without point-of-sale constraints.[6]History
Code 39, the first alphanumeric barcode symbology, was invented in 1974 by Dr. David Allais and Ray Stevens at Intermec Corporation (now part of Honeywell).[7][8] This development addressed the limitations of earlier numeric-only barcodes, such as Code 2 of 7, by enabling the encoding of both letters and numbers, which was essential for more versatile tracking in industrial and military environments.[8][9] During the 1980s, Code 39 gained widespread adoption outside retail sectors, particularly in manufacturing, logistics, and defense. In 1981, the U.S. Department of Defense mandated its use for marking products under the Logistics Applications of Automated Marking and Reading Symbols (LOGMARS) program, standardizing it for military supply chain tracking.[10][11] This period also saw the introduction of the Full ASCII variant in the early 1980s, which expanded the character set to include lowercase letters, punctuation, and control characters by pairing standard symbols.[12] Standardization efforts formalized Code 39's specifications, beginning with the American National Standards Institute (ANSI) MH10.8M-1983, which defined its structure for industrial applications. Later, it was incorporated into international norms as ISO/IEC 16388, with the second edition published in 2007 specifying symbology characteristics, encoding, and decoding parameters. The standard was revised in its third edition in 2023 with minor technical corrections while maintaining backward compatibility.[1]Symbology Fundamentals
Character Set
Standard Code 39, as defined in ISO/IEC 16388, supports a character set of 43 symbols comprising the decimal digits 0 through 9, the uppercase letters A through Z, and seven special characters: hyphen (-), period (.), space, dollar sign ($), forward slash (/), plus sign (+), and percent sign (%).[1] This base set excludes lowercase letters and the majority of punctuation marks, limiting the symbology to these alphanumeric and select symbolic representations for simplicity and reliability in industrial applications.[1] Each character in the set is encoded using a unique pattern consisting of nine elements: five bars and four intervening spaces, among which three elements are wide and six are narrow.[1] These patterns ensure distinctiveness during scanning, with the narrow elements typically measuring one unit (X) in width and wide elements measuring two or three units, though the exact ratio is specified further in symbology structure guidelines.[1] An intercharacter gap of one narrow unit separates adjacent characters within the symbol to facilitate accurate decoding by barcode readers.[1] Additionally, every Code 39 symbol begins and ends with the asterisk (*) character, which serves as the mandatory start/stop pattern but is not included in the encoded data content.[1]Encoding
Code 39 encoding begins with an input string consisting solely of the 43 valid characters: uppercase letters A-Z, digits 0-9, and the special characters space, minus (-), period (.), dollar ($), slash (/), plus (+), and percent (%).[13] Any invalid characters must be preprocessed or removed to ensure compliance, as the symbology does not support other symbols in its standard form.[3] The process requires prefixing and suffixing the input string with the asterisk (*) character, which serves as both the start and stop delimiter.[14] Each character in the augmented string (including the delimiters) is independently converted to a unique 9-module pattern comprising five bars and four spaces, where three elements are wide and six are narrow.[13] A module is defined as the smallest unit of measure, corresponding to the width of a narrow bar or space.[15] Wide elements are typically 2 to 3 times the width of narrow elements, providing the necessary contrast for reliable scanning without specifying exact ratios in the core symbology.[3] The full barcode sequence is constructed by concatenating these 9-module patterns in order, with a narrow intercharacter gap (equivalent to one module width) inserted between each pair of adjacent character patterns to separate them clearly.[14] Quiet zones, which are clear areas before the start character and after the stop character, follow general barcode printing standards (typically at least 10 modules wide) but are not uniquely specified for Code 39.[3] For example, to encode the string "ABC123", first form "ABC123". Each character's pattern (detailed in the Character Set section) is as follows, represented textually with "w" for wide and "n" for narrow elements in the sequence bar-space-bar-space-bar-space-bar-space-bar:- *: n w n n w n w n n
- A: w n n n n w n n w
- B: n n w n n w n n w
- C: w n w n n w n n n
- 1: w n n w n n n n w
- 2: n n w w n n n n w
- 3: w n w w n n n n n
- *: n w n n w n w n n
Symbol Structure
Bar and Space Patterns
Code 39 symbols are constructed using a discrete linear barcode symbology where each character is represented by nine alternating elements: five black bars and four white spaces.[13] Of these nine elements, exactly three are wide and six are narrow, creating the "3-of-9" designation.[13] The nominal width of the narrow element, known as the X dimension, has a minimum of 0.0075 inches (0.191 mm) and must remain constant throughout the symbol.[13] Wide elements are sized at a ratio (N) of 2.0:1 to 3.0:1 relative to narrow elements when X is 0.020 inches or greater, or 2.2:1 to 3.0:1 for smaller X dimensions, ensuring reliable differentiation during scanning.[13] The start and stop patterns are formed by the special character "*", which features wide elements in specific positions (the first, fifth, and ninth elements) to enable automatic recognition of symbol boundaries.[16] This configuration supports bidirectional reading, allowing scanners to process the symbol in either direction without ambiguity.[13] Overall symbol dimensions are variable in length, with a practical limit of up to 255 characters depending on printing and scanning constraints, though shorter lengths are typical for optimal readability.[17] The minimum bar height is 0.25 inches (6.35 mm) or 15% of the symbol length (excluding quiet zones), whichever is greater, to accommodate various scanning technologies.[13] As a discrete symbology, Code 39 requires clear intercharacter gaps equal to at least one X dimension (with tolerances), preventing adjacent characters from merging and ensuring accurate decoding.[13] Quiet zones on either end must be at least 10X or 0.10 inches (2.54 mm), whichever is larger, to isolate the symbol from surrounding elements.[13]Check Digit
Code 39 incorporates an optional check digit based on a modulo-43 checksum to detect transcription errors during data entry or scanning, though it is recommended for applications involving critical data to enhance reliability.[16] This mechanism verifies the integrity of the encoded message by ensuring the total sum of character values is divisible by 43, thereby catching single-character errors and most adjacent transpositions.[3] The calculation begins by assigning numeric values to each character in the data string, excluding the start and stop characters (denoted by *). The standard character set of Code 39 maps as follows: digits 0-9 retain their face values (0 through 9); uppercase letters A-Z are assigned 10 through 35 (A=10, B=11, ..., Z=35); and the special characters are mapped to 36 through 42 (-=36, .=37, space=38, $=39, /=40, +=41, %=42).[3][16] These assignments align with the positional order of the 43-character alphabet in the symbology.[18] To compute the check digit, sum the numeric values of all data characters, then apply the modulo-43 operation: \text{Check value} = \left( \sum \text{character values} \right) \mod 43 The resulting check value (ranging from 0 to 42) is then converted back to the corresponding character using the same mapping table; for instance, a remainder of 0 corresponds to '0', 10 to 'A', and 42 to '%'.[16] This check character is appended as the final data character immediately before the stop pattern (*).[18] For verification, the receiving system recalculates the sum of all character values, including the check digit, and confirms that the total modulo 43 equals zero; any deviation indicates an error.[3] This process provides robust detection without significantly increasing the symbol length, making it suitable for high-accuracy environments like healthcare and logistics.[16]Variants
Full ASCII Code 39
Full ASCII Code 39 extends the standard Code 39 symbology to encode the complete 128-character ASCII set by representing each extended character as a pair of standard Code 39 characters.[16] This method leverages four shift characters—$, /, %, and +—paired with the 26 uppercase letters A through Z to map to the additional symbols, resulting in a total coverage of all ASCII characters including those not in the base set of 43.[16] The shift characters function as prefixes that modify the interpretation of the following letter, allowing encoding of lowercase letters, punctuation, and control codes that are absent in standard Code 39.[19] In this encoding scheme, the first character of the pair is one of the shift symbols, and the second is a letter from A to Z, effectively using two Code 39 symbols to represent a single ASCII byte.[20] For example, the lowercase letter 'a' is encoded as +A, the exclamation mark '!' as /A, the start-of-heading control character (SOH) as $A, and the null character (NUL) as %U.[16] These pairs enable support for expansions such as lowercase a-z, symbols like @, [, ], {, }, and ~, as well as control characters from NUL (00) to DEL (7F), achieving full 128-character ASCII compatibility.[20] The following table provides representative examples of encoding pairs across different ASCII categories:| ASCII Character | Hex Value | Code 39 Pair | Category |
|---|---|---|---|
| ! | 21 | /A | Punctuation |
| " | 22 | /B | Punctuation |
| a | 61 | +A | Lowercase |
| b | 62 | +B | Lowercase |
| SOH | 01 | $A | Control |
| NUL | 00 | %U | Control |
| { | 7B | %P | Symbol |
| ~ | 7E | %S | Symbol |