Code 39, also called Code 3 of 9, encodes a set of 43 characters using nine elements, three of which are wide. Surprisingly this is not the source of the name. In the inventor David Allais’ own words:
“The structure of five bars and four spaces including two wide bars and one wide space came to me in flash. The two of five coding in the bars afforded ten combinations and the wide space provided for four separate groups. Setting aside one of the 40 possible characters as a start and stop pattern left 39 characters; hence the name Code 39.”
Still, when called Code 3 of 9 it is clear that the term implies that three elements out of the nine are wide. When it was invented in 1974 by Dr. David Allais and Ray Stevens of Intermec, all of the symbologies available at that time, with the sole exception of Codabar (which could only encode some letters and only in the start and stop character positions), were numeric only. Code 39 changed that and solved the problem of machine-readable marking of parts for manufacturers.
Structure and Design of the Symbology
Code 39 is a variable length symbology, being able to encode as few as zero characters (an empty message) up to 55 characters. Code 39 is still one of the most widely used barcodes in the world. Because of its alpha-numeric encoding capability it was adopted by the automotive industry, their suppliers and other manufacturers, many of them defense contractors and their biggest customer, the U.S. Department of Defense. Code 39 symbols will also be found in closed systems for warehouse inventory and encoding product serial numbers, etc.
In spite of the original design based on two wide bars and one wide space encoding a total of forty characters, “special” characters with three wide spaces and no wide bars were added to encode the additional “special” characters : – , $ / + % and the space character. Thus Code 39 can encode the entire upper case alphabet, the number digits 0 through 9, and these aforementioned special characters.
Code 39 uses bars and spaces of two widths, narrow and wide. For this reason, it is in a category of Symbologies known as “binary symbologies”. Narrow elements can be as small as 7.5 mil according to the official specification for Code 39 (ISO/IEC 16388 but is sometimes printed smaller in closed systems. The wide elements can be from two to three times a wide as the narrow elements. This Ratio should be consistent throughout a symbol.
Code 39 encodes characters in a pattern of 5 bars and 4 spaces, three of which are wide. This means that characters begin and end with a bar, and there is a need for a space to be placed in between characters. This dumb or non-significant inter-character gap separates encoded characters. Thus, Code 39 is also considered a “discrete symbology”.
Considerations – Pros and Cons
The ability to encode the full alphabet and numbers 0-9 was a unique capability in characters. An extension to the symbology, named Full ASCII Code 39 uses some of the characters to “shift” the next character to lower case, allowing lower case characters to be encoded. However, since the encoder and reader has to be in agreement as to whether this mode is in use, it is rarely used outside of specific closed systems.
Industry standards making use of Code 39 include the pharmaceutical industry in Italy which has specified a standard format and renamed the symbology Code 32 (since each character is used to encode 5-bits of numerical data).
Although Code 39 was a revolutionary symbology at its inception, later and more efficient alpha-numeric symbologies such as Code 128 have made it obvious how inefficient and limited Code 39 is, due to its relatively large space requirements. In an attempt to rectify this, Dr. Allais invented Code 93 which never gained wide acceptance.
Code 39 has the ability to incorporate a check digit which is optional. Again, since the encoder and decoder must be in agreement as to whether this mode is in use, it is rarely used in practice.
Code 39 is relatively easy to print, and owing to its inter-character gap, can be printed by discrete print wheels. Also, when used without its optional check digit (which is most often the case) it can be generated as a font in word processing and similar programs. Thus, it is relatively easy to employ Code 39 in a small, homegrown application.
Decoding of Code 39 is specified in ISO/IEC 16388. The width of each character is divided by 8 to obtain a threshold width that is nearly midway between the narrow and wide width. Each element is compared to this threshold to determine if it is narrow or wide. If the resulting pattern of wide and narrow elements matches a valid character, it is decoded, otherwise it is rejected. The Decodability value for Code 39 is similarly computed from the separation of the element widths from this threshold. The use of a larger Ratio, and a larger X dimension normally results in symbols that are easier to print with acceptable values for Decodability.