About the Code 128 Barcode Symbology

The 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.

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).

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.

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.

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.

* 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 Macintosh,
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:

Reference the character set
table to obtain the value of the start character and all data
characters.

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.

Multiply the character values by their weights for the data
characters.

Add these together including the start character, divide by
103 and obtain the remainder.

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 B

b

i

z

STP

weighting

1

2

3

values

104

66

73

90

totals

104

66

146

270

Calculate the Total: 104+ (66*1) + (73*2) + (90*3) =
586

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.

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.

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 encodeCode[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) & DataString2Java: 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 Size

Approximate X dimension (1 mil = .001")

48

.102 cm

40 mil

36

.076 cm

30 mil

32

.069 cm

27 mil

30

.064 cm

25 mil

28

.058 cm

23 mil

24

.051 cm

20 mil

20

.043 cm

17 mil

18

.038 cm

15 mil

16

.033 cm

13 mil

12

.025 cm

10 mil

8

.018 cm

7 mil

6

.013 cm

5 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, 36

4, 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 Name

Evaluation Font Name*

Font Height*

N Dimension**

IDAutomationC128XXS

IDAutomationSC128XXS

.10" or .254 CM

10

IDAutomationC128XS

IDAutomationSC128XS

.20" or .508 CM

20

IDAutomationC128S

IDAutomationSC128S

.35" or .889 CM

35

IDAutomationC128M

IDAutomationSC128M

.50" or 1.27 CM

50

IDAutomationC128L

IDAutomationSC128L

.60" or 1.46 CM

58

IDAutomationC128XL

IDAutomationSC128XL

.75" or 1.90 CM

75

IDAutomationC128XXL

IDAutomationSC128XXL

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.