Code 39 Barcode FAQ & Tutorial

Barcode Information | Tutorials | Examples

Code 39 Barcode Symbology Overview

Code 39 is a common barcode type used for various labels such as name badges, inventory, and industrial applications. The symbology of the Code 39 character set consists of barcode symbols representing numbers 0-9, upper-case letters A-Z, the space character, and the following symbols: – . $ / + %. Lower-case characters may also be easily encoded with the extended fonts provided in the IDAutomation Code-39 Font Package.

The Code 39 barcode is the easiest of the alpha-numeric barcodes to use and is designed for character self-checking, thus eliminating the need for check character calculations. Code 39 is also known as the 3 of 9 Barcode, Code 3 of 9, and Barcode39. Several standards exist that dictate how Code 39 barcodes should be printed for certain implementations. Although a checksum character is optional, many standards require it. The checksum character is a type of MOD43 calculation provided in many of the IDAutomation font encoders for the Code 39 Barcode Fonts. Enabling the check digit is also an option within IDAutomation Barcode Components and Applications that allow the component to automatically generate and include the MOD43 checksum without fonts.

The following standards based on the 3 of 9 barcode require MOD43 check digits:

  • LOGMARS (Logistics Applications of Automated Marking and Reading Symbols) is a standard based on Code 39 used by the United States Department of Defense. LOGMARS is defined by Military Standard MIL-STD-1189B and others such as MIL-STD-129, MIL-STD-2073-1C, and MIL-STD-129N.
  • HIBC (Health Industry Barcode) is a barcode label used in the healthcare product industry. Several implementations of HIBC also use Code 128.

The complete Code 39 barcode (shown below) consists of a start character (*), data digits (CODE-39), an optional check character (P), and a stop character (*).

The complete Code 39 barcode (shown below) consists of a start character (*), data digits (CODE-39), an optional check character (P), and a stop character (*)

The Code 39 asterisk character is usually used as a start/stop character, and should not be part of the data in the barcode. The asterisk may be used as the start/stop character with fonts; however, this may cause problems in some applications such as MS Word, because they may treat text surrounded with asterisks as bold text. In IDAutomation Code 39 barcode fonts, the exclamation and parentheses characters are also used as start/stop characters to avoid these problems and provide additional functionality. The parentheses are also used to keep the asterisks showing up in the HR text below the barcode. The following barcode example uses parentheses to eliminate the asterisks shown in the text interpretation.

The following barcode example uses parentheses to eliminate the asterisks shown in the text interpretation.

To generate that barcode above with IDAutomation Code 39 fonts, choose the font and type (CODE-39) instead of *Code-39*.

Printing & Generating Code 39 Barcodes

Printing the Code 39 barcode as a font is an easy process if checksum characters are not required for the implementation. If the checksum is needed, IDAutomation provides several Font EncodersComponents, and Applications for this purpose.

IDAutomation Code 39 Barcode Fonts may be created directly from the keyboard or used in a calculated field to dynamically produce multiple symbols in many applications, including Microsoft WordExcel, Crystal Reports, FileMakerQuickBooks, and OpenOffice.

To create a 3 of 9 barcode manually that encodes the data “BAR CODE-39”, the following may be performed:

  1. Type the start character of “*”.
  2. Enter the data to be encoded, which is “BAR CODE-39”.
  3. To create the space in the barcode using the standard Code 39 Fonts, an underscore must replace the space in the data to encode: “BAR_CODE-39”.
  4. Type the stop character of “*” .
  5. Select only *BAR_CODE-39* and change the font to the Code 39 Barcode Font.

When the IDAutomation Code 39 Barcode Font is used, the parenthesis may be used as the start and stop characters to keep the asterisks from appearing in the text interpretation. For example, (BAR_CODE-39). This functionality is exclusive to the IDAutomation Code 39 Fonts.

2014 Update: IDAutomation now provides Symbol Encoded Fonts that encode the space character without a substitution character; available in the latest version of the IDAutomation Code 39 Fonts. After installation, these fonts are identified by the “Y” character in the font name, for example, IDAutomationYHC39S.

Calculated Field Use

Code 39 Barcodes may be dynamically created from a calculated field in a text box by using a formula that appends the start and stop characters. This is possible in several applications including the following:

  • Active Reports: Field1.Text =”*”&Field&”*” example…
  • Clarion: loc:barcode=’*’&left(clip(DataField))&’*’
  • Crystal Reports: Enter “*” & Field & “*” in a calculated field.
  • FileMaker Pro: Enter “*” & Field & “*” in a calculated field so that the asterisk is appended to the beginning and end of the data from the source field.
  • Lotus Notes: A formula that places a return function (in extended39) between fields: “*” + DataField1 + “$M” + DataField2 + “*”
  • Lotus Approach: Combine(‘*’, DataField, ‘*’) – Here is an approach formula that also replaces spaces with the “=” character as required: Combine(‘*’, Translate(DataField,’ ‘,’=’), ‘*’)
  • Lotus 123 for Windows: (“*”&C3&”*”) – this formula converts a number in cell C9 to text for barcoding:(“*”&@STRING(C9,0)&”*”)
  • Microsoft® Access: =(“(“&[Table.Field1]&”)”)
  • Microsoft® Excel: =(“(“&C3&”)”)
  • Oracle Reports and Forms – Place an asterisk before and after the data and apply IDAutomation’s barcode font to the field.
  • QuickBooks: Refer to IDAutomation’s QuickBooks Barcode Tutorial.

Implementation Tutorials for the Code 39 Font

Reading Code 39 Barcodes

The most common method of reading barcodes is with a barcode scanner. Most barcode scanners recommended by IDAutomation perform keyboard emulation and receive power from the USB port so that no external power supply is required. When a barcode is scanned using keyboard emulation, the data scanned appears at the cursor as if it had been typed in from the keyboard.

Most barcode scanners have the ability to read Code 39 barcodes by default, such as the IDAutomation USB Barcode Scanner. This scanner dependably reads the IDAutomation Code 39 Barcode Font and Universal Barcode Font when printed as small as 6 points, which is an X dimension of 4 mils.

MOD43 Check Character Calculation Examples | Verification

MOD43 check characters may be verified with the free Barcode Data Decoder App, which scans the barcode and highlights the check digit in green when the calculation is correct.

The Barcode Data Decoder App scans the barcode and highlights the check digit in green when the calculation is correct.

The manual calculations described below are rarely necessary. IDAutomation provides several barcode font tools, plug-ins, and source code samples that are free to use with IDAutomation fonts, which automatically format the start, stop, and check characters to the barcode fonts. Additionally, the check digit option in all Components and Applications calculate and include the checksum automatically.

Perform the following to calculate the optional modulus 43 check character manually:

  1. Using the table below, obtain the number value of each data character.
  2. Add all of these values together.
  3. Divide the total by 43 and obtain the remainder.
  4. The check character is the value of the remainder.

For example, perform the following calculations to determine the check character using the data characters “CODE39”:

  1. The values are 12, 24, 13, 14, 3 and 9.
  2. When added together, these total 75.
  3. Now divide 75 by 43 and the remainder is 32.
  4. The check character is W

Code 39 Character Values:


Encoding ASCII Character Set in Extended Code 39:

Within the IDAutomation Code-39 Font Packageextended fonts are provided to easily encode lower-case characters in addition to upper-case letters and numbers. When these fonts are not being used, or when it is necessary to encode additional characters, shift functions may be used to extend the character set according to ISO 646. In order for Extended Code 39 to be decoded properly, the scanner must first be programmed to read it. Otherwise, the scanner will simply scan the existing data, for example, “+C” instead of “c.”

When extended Code 39 is enabled, functions may be directly encoded by using the format $? to specify the function where ? equals the character that represents the appropriate function in the chart below. For example, Code$I3of9$M will encode Code[TAB]3of9[RETURN].

The Extended Code 39 ASCII Character Table
 Extended Code 39 ASCII Character Table
 ASCIICode39ASCIICode39ASCIICode39ASCIICode39ASCII (Functions)Code39
 AAa+A00ESC (Escape)%ASH (Start of Heading)$A
 BBb+B11FS (File Separator)%BSX (Start of Text)$B
 CCc+C22GS (Group Separator)%CEX (End of Text)$C
 DDd+D33RS (Record Separator)%DET (End of Transmission)$D
 EEe+E44US (Unit Separator)%EEQ (Enquiry)$E
 FFf+F55;%FAK (Acknowledge)$F
 GGg+G66<%GBL (Bell-Audible of Attention Signal)$G
 HHh+H77=%HBS (Backspace)$H
 IIi+I88>%IHT (Horizontal Tabulation)$I
 JJj+J99?%JLF (Line Feed)$J
 KKk+K!/A[%KVT (Vertical Tabulation)$K
 LLl+L/B\%LFF (Form Feed)$L
 MMm+M#/C]%MCR (Carriage Return)$M
 NNn+N$/D^%NSO (Shift Out)$N
 OOo+O%/E_%OSI (Shift In)$O
 PPp+P&/F{%PDL (Data Link Escape)$P
 QQq+Q/G|%QD1 (Device Control 1-XON)$Q
 RRr+R(/H}%RD2 (Device Control 2)$R
 SSs+S)/I~%SD3 (Device Control 3-XOFF)$S
 TTt+T*/JDEL%TD4 (Device Control 4)$T
 UUu+U+/KNU (Null)%UNK (Negative Acknowledge)$U
 VVv+V,/L@%VSY (Synchronous Idle)$V
 WWw+W/M`%WEB (End of Transmission Block)$W
(= or ~ in the fonts)
SPCN (Cancel)$X
 YYy+Y//OEM (End of Medium)$Y
 ZZz+Z:/ZSB (Substitute)$Z

A space symbol cannot usually be represented from a font with an actual space (ASCII 32). To overcome this issue with Code 39 Fonts:

  • Replace the symbol representing a space with the underscore “_” character. In IDAutomation Extended Code 39 barcode fonts, the “~” (tilde) character is used for a space.
  • Use the Symbol Encoded Fonts that encode the space character without a substitution character; Available in the latest version of the IDAutomation Code 39 Fonts.