Code 128/GS1-128 Barcode FAQ & Tutorial

Barcode Information Tutorials & FAQs at BarcodeFAQ.com

About the Code 128 Barcode Symbology

GS1-128 Bar Code example created with Code-128The Code 128 barcode is a high-density linear symbology that encodes text, numbers, numerous functions and the entire 128 ASCII character set (from ASCII 0 to ASCII 128.) It is commonly used for several implementations; and is also referred to as ISBT-128, GS1-128, UCC-128, EAN-128 and USS Code 128.

Code 128 contains 106 different printed barcode patterns. Each printed barcode may have one of three different meanings depending upon which of the character sets are being used, with the availability of three different Code 128 start characters to program the initial character set. Functions are also provided in the barcode symbology to switch between character sets and encode Application Identifiers. The Code 128 barcode may be complex to use because of the different character sets, which is the primary reason IDAutomation provides the Code 128 auto function, “Code128( )”, in several of the Font Tools, Components and Applications.

The complete Code 128 barcode consists of a start character, data digits, a modulo 103 check digit and a stop character.

 Start Character

Data Digits

Check Character

Stop Character

 ÌCODE-128OÎ
 

The above Code 128 barcode symbol was created with the IDAutomation Barcode Image Generator.

Various Standards for Code 128 Barcode Symbology

Several standards exist that dictate how Code 128 barcodes should be generated for certain implementations; a few of these include:

  • GS1-128 (previously known as UCC-128 and EAN-128) is defined by GS1 and used to create several types of barcode symbols that include Application Identifiers. Application Identifiers (AIs) define the purpose of the data in the symbol and how it is to be used.
  • ISBT-128 is specifically designed for printing blood product barcode labels. It was developed by the International Society of Blood Transfusion (ISBT) and the Working Party on Automation and Data Processing (WPADP).
  • USS Code 128 (Uniform Symbology Specification Code 128) is the published specification for the Code 128 barcode.
  • ISS Code 128 (International Symbology Specification Code 128) is the USS Code 128 barcode symbology with a new feature that allows the encoding of extended ASCII characters for non-English languages.
  • The Global Trade Item Number (GTIN), or previously known as EAN14, is the product identification structure in the GS1 (EAN/UCC) system. The GTIN is a 14 digit fixed length numeric string, including the indicator digit (or logistic variant), the EAN/UCC company prefix, item reference and check digit. When using the GS1-128 barcode symbology, the data will need to be appended with the Fnc1 character and an Application Identifier of 01. The GTIN should always be stored in databases as a 14-digit number. When the GTIN is represented in UPC-A, UPC-E, GTIN-8 and GTIN-13, as 8, 12, or 13 digits, it should be stored as a 14-digit number by appending zeros to the beginning of the data.
  • SSCC-18 is a serialized shipping label specification.

Products for Printing Code 128 Barcodes

Several Barcode Integration Guides are available that suggest various barcode printing options. These integration options should be examined to determine whether to use barcode components, applications or fonts for the printing of barcodes. A few of the Barcode Integration Guides offered include the following:

Featured Product:

The IDAutomation Universal Barcode Font Advantage Package is a unique product that excels at generating barcode 128 on multiple operating systems and locales, including Double Byte versions of Windows. This package overcomes the obstacles that sometimes occur when printing Code 128 as a barcode font outside of the Unites States.

Reading & Scanning Code 128 Barcodes

The most common method of reading code 128 barcodes is with a linear barcode scanner. Most of the barcode scanners recommended by IDAutomation perform keyboard emulation and receive power from the USB port, so 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 from the keyboard.

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

The USS Code-128 Character Set

IDAutomation provides several font tools, macros and source code samples that may be used royalty-free with IDAutomation barcode fonts, which automatically format the data being encoded to the barcode fonts. Therefore, references to this character set may not be necessary.

The three character sets listed below are for the Code 128 barcode. In the columns A, B and C, are listed the character or function the barcode scanner will read for the associated symbol. The “ASCII” and “Unicode” columns designate the location where the barcode symbol for the character resides. The column “Char” lists the character that resides at the ASCII location, which is used to print the corresponding symbol. The ASCII location for the space character, stop character and character values 94-105 are applicable only to IDAutomation products including the Code 128 Barcode Fonts. The ISO specification for Code 128 does not specify the location of ASCII and Unicode values for these symbols.

USS Code-128 Character Set
 Code ACode BCode CASCII *Unicode *CharValueCode ACode BCode CASCII *Unicode *CharValue
 SpaceSpace00 019400C2Â00VV5400860056V54
 !!0100330021!01WW5500870057W55
 “020034002202XX5600880058X56
 ##0300350023#03YY5700890059Y57
 $$0400360024$04ZZ580090005AZ58
 %%0500370025%05[[590091005B[59
 &&0600380026&06\\600092005C\60
 ‘070039002707]]610093005D]61
 ((0800400028(08^^620094005E^62
 ))0900410029)09__630095005F_63
 **100042002A*10nul`6400960060`64
 ++110043002B+11soha6500970061a65
 ,,120044002C,12stxb6600980062b66
 –130045002D13etxc6700990063c67
 ..140046002E.14eotd6801000064d68
 //150047002F/15enoe6901010065e69
 001600480030016ackf7001020066f70
 111700490031117belg7101030067g71
 221800500032218bsh7201040068h72
 331900510033319hti7301050069i73
 442000520034420lfj740106006Aj74
 552100530035521vtk750107006Bk75
 662200540036622ffl760108006Cl76
 772300550037723crm770109006Dm77
 882400560038824s0n780110006En78
 992500570039925s1o790111006Fo79
 ::260058003A:26dlep8001120070p80
 ;;270059003B;27dc1q8101130071q81
 <<280060003C<28dc2r8201140072r82
 ==290061003D=29dc3s8301150073s83
 >>300062003E>30dc4t8401160074t84
 ??310063003F?31naku8501170075u85
 @@3200640040@32synv8601180076v86
 AA3300650041A33etbw8701190077w87
 BB3400660042B34canx8801200078x88
 CC3500670043C35emy8901210079y89
 DD3600680044D36subz900122007Az90
 EE3700690045E37esc{910123007B{91
 FF3800700046F38fs|920124007C|92
 GG3900710047G39gs}930125007D}93
 HH4000720048H40rs~940126007E~94
 II4100730049I41usdel95019500C3Ã95
 JJ420074004AJ42fnc 3fnc 396019600C4Ä96
 KK430075004BK43fnc 2fnc297019700C5Å97
 LL440076004CL44ShiftShift98019800C6Æ98
 MM450077004DM45code Ccode C99019900C7Ç99
 NN460078004EN46code Bfnc 4code B020000C8È100
 OO470079004FO47fnc 4code Acode A020100C9É101
 PP4800800050P48fnc 1fnc 1fnc 1020200CAÊ102
 QQ4900810051Q49Start AStart AStart A020300CBË103
 RR5000820052R50Start BStart BStart B020400CCÌ104
 SS5100830053S51Start CStart CStart C020500CDÍ105
 TT5200840054T52StopStopStop020600CEÎna
 UU5300850055U53

* If it is necessary to print the Code 128 space character from ASCII 194 instead of ASCII 32 because some applications do not print a symbol instead of a space character. The ASCII location for the space character, stop character and character values 94-105 are applicable only to IDAutomation barcode products including the Barcode 128 Fonts. Additionally, the characters listed for values 00 and 94-105 are from the Latin-1 codepage. When the Latin-1 codepage is not being used, or when using a Mac, it is suggested to use the Universal Barcode Font Advantage™, which creates Code 128 barcodes as a font in any codepage and operating system.

Code 128 Check Character Calculation Examples

IDAutomation provides several font tools, plug-ins and source code samples that are free to use with IDAutomation barcode fonts, which will automatically format the start, stop and check characters to the barcode fonts. Therefore, the manual calculations described here are rarely necessary.

The following examples create a barcode with the IDAutomation Code 128 Barcode Fonts in the Latin-1 codepage, which is the default setting in the USA. When the Latin-1 codepage is not being used, or when using a Mac, it is suggested to use the Universal Barcode Font Advantage™, which creates the Code 128 barcode as a font in any codepage and operating system.

The following process is used to determine the value of the check character:

  1. Reference the character set table to obtain the value of the start character and all data characters.
  2. Assign a weight to each data character (not the start character, just the data characters.) The weighting starts at 1 and increases by one for each data character.
  3. Multiply the character values by their weights for the data characters.
  4. Add these together including the start character, divide by 103 and obtain the remainder.
  5. Use the character set table to locate the character that has the value of the remainder, use this as the check character.

Calculation Example for Character Set A or B:

The following table is an example of how to obtain the check character for the data “biz” using Code 128 character set B.

Start BbizSTP
 weighting123
 values104667390
 totals10466146270
  1. Calculate the Total: 104+ (66*1) + (73*2) + (90*3) = 586
  2. Calculate the Checksum: 586 divided by 103 = 5 remainder of 71. Therefore, the check digit equals a value of 71. The character to print for the value of 71 is “g” or ASCII 103.
  3. To print the data “biz” as a barcode, the text of ÌbizgÎ is combined with the Code 128 Barcode Fonts.
Calculation Example for Character Set C:

The following table is an example of how to obtain the check character for the number “667390” using character set C.

Start C667390SOP
 weighting123
 values10566790
 totals10566146270
  1. Separate the numbers into pair and choose the appropriate character from the character set table that represents the number pair.
  2. Calculate the Total: 105 + (66*1) + (73*2) + (90*3) = 587
  3. Calculate the Checksum: 587 divided by 103 = 5 remainder of 72. Therefore, the check digit equals a value of 72. The character to print for the value of 72 is ASCII 104.
  4. To print the data “667390” as a barcode, the text of ÍbizhÎ is combined with the Code 128 Barcode Fonts.
Calculation Example for Multiple Character Sets:

The following table is an example of how to encode the data “biz” using Code 128 character set B with a switch to character set A for a carriage return function.

Start BbizÉmSTOP
 weighting12345
 values10466739010177
 totals1046614627040435
  1. Calculate the Total: 104 + (661) + (73*2) + (90*3) + (101*4) + (77*5) = 1375
  2. Calculate the Checksum: 1375 divided by 103 = 13 remainder of 36. The check digit equals a value of 36. The character to print for the value of 36 is “D” or ASCII 68.

Switching Between Sets & Encoding Functions

Encoding functions such as returns and tabs may make data entry tasks easier. Functions are easily encoded with the appropriate ASCII function code. Normally, these characters are not visible unless an application is used such as IDAutomation’s Barcode Scanner ASCII String Decoder, which displays these hidden functions as tags.

Easily encode functions with Set A:

Use Character Set A and convert all text data to UPPERCASE. Be careful with this method because anything lowercase in set A will create a function! Then use the letter “i” for a tab and “m” for a return. Other functions can be determined by looking up the column for Code A on the character set chart and choosing the associated character. For example: The following character string in character set A encodes the data “JOHN<tab>SMITH<tab>128-288-6794<return>”.
JOHNiSMITHi128-288-6794m

Using the shift function in Set B:

Use Character Set B and perform a shift to set A to encode tabs, returns and other functions. Then use just the letters “Æi” for a tab and “Æm” for a return where “Æ” is ASCII 198 or Unicode 00C6.

For example:
The following character string in character set B encodes the data “John<tab>Smith<tab>349-128-6794<return>”.
JohnÆiSmithÆi349-128-6794Æm

Manual character set switching:

It is suggested to use character set shift methods (described above) if possible. The following switch methods work with all of IDAutomation’s Code 128 products:

When the character set is A or B, switching between character sets is accomplished by placing the appropriate ASCII code of the switch function from the chart in the data to encode.

For example, if you select Set B and you specify the data “bizÉmiÈfonts.com” (“É” is the switch to set A, “m” is the return and “i” is the tab function and “È” is the switch back to set B according to the chart) as the input for the Code 128 B function, the barcode generated would perform the switch to set A and the function of a return plus a tab when scanned by a barcode scanner.

Functions can also be used without any switching if the character set is already A. For example, if you specify the data “BIZm” (“m” is the function according to the chart) as the input for the Code 128 A function, the barcode scanner would read “BIZ” and then a return function.

It is suggested that Mac users use the Universal Barcode Font Advantage™, which creates Code 128 barcodes as a font in any codepage and operating system.

Automatic Encoding with Code 128 Auto:

Functions may be directly encoded in IDAutomation products by enabling “ApplyTilde” in Code128 Auto, and using the format ~??? to specify the ASCII code of the function. For example, Code~009Bar~013 will encode Code[TAB]Bar[RETURN].

When ApplyTilde is not available, the programming code syntax for the ASCII function code may be used in the formula for the DataToEncode. For example, the following formulas combine two fields in a single barcode with a tab function separator:
Crystal Reports: IDAutomation_Code128 ({Table1.DataField1} & Chr(9) & {Table1.C128})
Microsoft Access: =( [Table1.Field1] & Chr(9) & [Table1.Field2] )
VB .NET: DataToEncode =DataString1 & Chr(9) & DataString2
Java: DataToEncode =DataString1 + (char)9 + DataString2;

Encoding Functions with Set A:

Caution should be used in character set A because any lowercase letter will create a function according to the chart. Use the letter “i” for a tab and “m” for a return. Other functions may be determined by looking up the column for Code A in the character set chart. For example, the following character string in character set A encodes the data “JOHN[tab]SMITH[tab]128-288-6794[return]”:
JOHNiSMITHi128-288-6794m

Code 128 Barcode Font Specifications

IDAutomation Code 128 Barcode Fonts include several sizes to meet various height and width requirements, including GS1-128 sizes. The X dimension (X is the width of the narrow bar) is listed below for various point sizes in millimeters and mils. 1 mil is equal to 1/1000 of an inch. IDAutomation’s Code 128 barcode fonts have been specially designed to be able to produce dependable barcodes when printed at large and small point sizes.

 Point SizeApproximate X dimension (1 mil = .001″)
 48.102 cm40 mil
 36.076 cm30 mil
 32.069 cm27 mil
 30.064 cm25 mil
 28.058 cm23 mil
 24.051 cm20 mil
 20.043 cm17 mil
 18.038 cm15 mil
 16.033 cm13 mil
 12.025 cm10 mil
 8.018 cm7 mil
 6.013 cm5 mil

* To print at a different X dimension, find the point size that has the X dimension closest to what is needed and use the formula below to find the point size needed:
12 * (X dimension needed) / (X dimension at 12 points) = (point size) For example, to obtain an X dimension of 12 mils, the point size should be 14:
12 * 12 / 10 = 14

When using a printer with less than 600 DPI, print at the following point sizes to create accurate barcodes:
 203 DPI Printer (thermal printer)300 DPI Printer
 6, 12, 18, 24, 30, 364, 8, 12, 16, 20, 24, 28, 32, 36

The height and N Dimension for each font type is listed in the chart below. Each font may be printed at various point sizes to allow several combinations of heights and widths.

 Purchased Font NameEvaluation Font Name*Font Height*N Dimension**
 IDAutomationC128XXSIDAutomationSC128XXS .10″ or .254 CM  10
 IDAutomationC128XSIDAutomationSC128XS .20″ or .508 CM  20
 IDAutomationC128SIDAutomationSC128S .35″ or .889 CM  35
 IDAutomationC128MIDAutomationSC128M .50″ or 1.27 CM  50
 IDAutomationC128LIDAutomationSC128L .60″ or 1.46 CM  58
 IDAutomationC128XLIDAutomationSC128XL .75″ or 1.90 CM  75
 IDAutomationC128XXLIDAutomationSC128XXL 1″ or 2.54 CM  100

* Measurements are approximate and were measured when printed at 12 points.

To print at a different height, find the font that has the height closest to what is needed and use the following formula to find the point size that is needed:
12 * (height you want) / (height at 12 points) = (point size converted to integer)
For example, if using IDAutomationC128M and the height is to be .75″, it should be printed at 18 points:
12 * .75 / .5 = 18

** The N Dimension column in the chart is the narrow bar width to font height ratio.