Barcode

Message Forum

Symbology
Specifications

News

Links

Barcode Printers

Services

Contact Us

Legal Info

Privacy Policy

CODE 39 SYMBOLOGY

See Also:    Symbology Index



Quick Links:   Background    Check Digit    Encoding    Structure    Encoding Table    Example    Full ASCII Mode


CODE 39 BACKGROUND INFORMATION

Code 39, the first alpha-numeric symbology to be developed, is still widely used-especially in non-retail environments. It is the standard bar code used by the United States Department of Defense, and is also used by the Health Industry Bar Code Council (HIBCC). Code 39 is also known as "3 of 9 Code" and "USD-3".

A typical Code 39 bar code is:

Code 39 is a discrete, variable-length symbology. It is self-checking in that a single print defect cannot transpose one character into another valid character.

COMPUTING THE CHECKSUM DIGIT

Since Code 39 is self-checking, a check digit normally isn't necessary. However, in applications that require an extremely high level of accuracy a modulo 43 checksum digit may be added.

To calculate the optional checksum digit, follow the following steps.

  1. Take the value (0 through 42) of each character in the bar code. The start and stop characters are not included in the checksum calculation.
  2. Sum the value of each of the values of each of the characters described in step 1.
  3. Divide the result from step 2 by 43.
  4. The remainder from the division in step 3 is the checksum character that will be appended to the data message before the stop character.

ENCODING THE SYMBOL

Once the checksum digit has been calculated we know the entire message which must be encoded in the bars and spaces. Continuing with our example, we will encode, from zero, the Code 39 bar code we used in our example above: HI345678 with a checksum digit of 67.

In the following text, we will discuss the encoding of the bar code by considering that the number "1" represents a "dark" or "bar" section of the bar code whereas a "0" represents a "light" or "space" section of the bar code. Thus the numbers 1101 represents a double-wide bar (11), followed by a single-wide space (0), followed by a single-wide bar (1). This would be printed in the bar code as:


STRUCTURE OF A CODE 39 BARCODE

A Code 39 bar code has the following structure:

  1. A start character - the asterisk (*) character.
  2. Any number of characters encoded from the table below.
  3. An optional checksum digit calculated as described above and encoded from the table below.
  4. A stop character, which is a second asterisk character.

CODE 39 ENCODING TABLE

This table indicates how to encode each digit of a Code 39 bar code. Note that the "Width Encoding" column is expressed as "N" for narrow and "W" for wide while the "Barcode Encoding" column represents how the bar code will actually be encoded as described above in "Encoding the Symbol."

Keep in mind that each character begins and ends with a bar, thus the "bar code encoding" always starts and ends with a "1".

CHECK
VALUE
ASCII
CHAR
WIDTH
ENCODING
BARCODE
ENCODING
CHECK
VALUE
ASCII
CHAR
WIDTH
ENCODING
BARCODE
ENCODING
0 0 NNNWWNWNN 101001101101 22 M WNWNNNNWN 110110101001
1 1 WNNWNNNNW 110100101011 23 N NNNNWNNWW 101011010011
2 2 NNWWNNNNW 101100101011 24 O WNNNWNNWN 110101101001
3 3 WNWWNNNNN 110110010101 25 P NNWNWNNWN 101101101001
4 4 NNNWWNNNW 101001101011 26 Q NNNNNNWWW 101010110011
5 5 WNNWWNNNN 110100110101 27 R WNNNNNWWN 110101011001
6 6 NNWWWNNNN 101100110101 28 S NNWNNNWWN 101101011001
7 7 NNNWNNWNW 101001011011 29 T NNNNWNWWN 101011011001
8 8 WNNWNNWNN 110100101101 30 U WWNNNNNNW 110010101011
9 9 NNWWNNWNN 101100101101 31 V NWWNNNNNW 100110101011
10 A NNWWNNWNN 110101001011 32 W WWWNNNNNN 110011010101
11 B NNWNNWNNW 101101001011 33 X NWNNWNNNW 100101101011
12 C WNWNNWNNN 110110100101 34 Y WWNNWNNNN 110010110101
13 D NNNNWWNNW 101011001011 35 Z NWWNWNNNN 100110110101
14 E WNNNWWNNN 110101100101 36 - NWNNNNWNW 100101011011
15 F NNWNWWNNN 101101100101 37 . WWNNNNWNN 110010101101
16 G NNNNNWWNW 101010011011 38 SPACE NWWNNNWNN 100110101101
17 H WNNNNWWNN 110101001101 39 $ NWNWNWNNN 100100100101
18 I NNWNNWWNN 101101001101 40 / NWNWNNNWN 100100101001
19 J NNNNWWWNN 101011001101 41 + NWNNNWNWN 100101001001
20 K WNNNNNNWW 110101010011 42 % NNNWNWNWN 101001001001
21 L NNWNNNNWW 101101010011 n/a * NWNNWNWNN 100101101101

If a Code 39 bar code starts with a space, that bar code will be appended to any previous code 39 bar code in the buffer and the system will wait for additional bar code(s). If a Code 39 bar code doesn't start with a space, the bar code will be appended to any previous code 39 bar codes and the entire message will be delivered to the application.

In other words, if a code 39 bar code has additional bar codes to follow, it must start with a space-if the bar code is the last bar code in the message it must not start with a space.

CODE 39 ENCODING EXAMPLE

We will now code the example we used above, TEST8052. In this case we will not use a check digit.

  1. The START character (*): 100101101101.
  2. The digit "T": enocded as 101011011001.
  3. The digit "E": enocded as 110101100101.
  4. The digit "S": enocded as 101101011001.
  5. The digit "T": enocded as 101011011001.
  6. The digit "8": enocded as 110100101101.
  7. The digit "0": enocded as 101001101101.
  8. The digit "5": enocded as 110100110101.
  9. The digit "2": enocded as 101100101011.
  10. The STOP character (*): 100101101101.
This is shown in the following graphical representation where the bar code has been sectioned-off into areas that reflect each of the 10 components just mentioned.

    NOTE: In the above encoding example note that there is an inter-character space between each character. This is not listed in the list of 10 components, but there is an inter-character space between each character. This inter-character space is represented in the graphic by the white space separating the grey areas.

EXTENDED CODE 39 ENCODING TABLE

It is possible, using Code 39's "Full ASCII Mode" to encode all 128 ASCII characters. This is accomplished by using the $, /, %, and + symbols as "shift" characters. Those characters combined with the single character that follows indicate which Full ASCII character is to be used.

ASCII ENCODING ASCII ENCODING ASCII ENCODING ASCII ENCODING
NUL %U SP Space @ %V ` %W
SOH $A ! /A A A a +A
STX $B " /B B B b +B
ETX $C # /C C C c +C
EOT $D $ /D D D d +D
ENQ $E % /E E E e +E
ACK $F & /F F F f +F
BEL $G ' /G G G g +G
BS $H ( /H H H H H
HT $I ) /I I I i +I
LF $J * /J J J j +J
VT $K + /K K K k +K
FF $L , /L L L l +L
CR $M - - M M m +M
SO $N . . N N n +N
SI $O / /O O O o +O
DLE $P 0 0 P P p +P
DC1 $Q 1 1 Q Q q +Q
DC2 $R 2 2 R R r +R
DC3 $S 3 3 S S s +S
DC4 $T 4 4 T T t +T
NAK $U 5 5 U U u +U
SYN $V 6 6 V V v +V
ETB $W 7 7 W W w +W
CAN $X 8 8 X X x +X
EM $Y 9 9 Y Y y +Y
SUB $Z : /Z Z Z z +Z
ESC %A ; %F [ %K { %P
FS %B << %G \ %L | %Q
GS %C = %H ] %M } %R
RS %D > %I ^ %N ~ %S
YS %E ? %J _ %O DEL %T, %X, %Y, %Z

© Copyright 2006 BarCodeIsland.com, Inc. All Rights Reserved.
Information provided "as-is" without warranty. Please
see details.
Contact us for usage and copy permission.