Code 128/GS1-128 Barcode FAQ & Tutorial
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.
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-128 |
O |
Î |
 |
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.
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.
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 Code 128 barcode symbology is used to create GS1-128 (formerly
UCC128 or EAN128) barcodes such as the GS1-128 symbols and data
structure for
SSCC18
and SCC14. Every GS1-128 barcode begins with a Start C character followed
by a (FNC1)
"Function Code One" and an
Application Identifier (AI) number. The AI defines a specific purpose for
the data field after it. The the combination of a the AI and its data field is
referred to as the element string. Below are some of the requirements for
GS1-128 and how to implement them in IDAutomation products.
- Symbol Size:
According to GS1-128 specifications, the height of the barcode
should be 15% of the length or 0.50 inch (1.3 CM), whichever is
greater. The X dimension may range from 10 mils (.025 cm) to 40
mils (.1 cm). When the X dimension used is between 10 and 16 mils,
the symbol should be 0.50" tall. When the X dimension used is between
16 and 40 mils, the symbol should be 1.25" tall. The X dimension
of 10 mils (0.10") is recommended for use with most
hand-held scanners.
The IDAutomation
Code 128 Barcode
Font IDAutomationC128M and
Universal
Barcode Font IDAutomation Uni M are specifically designed for
this purpose. They are exactly 0.50" tall with an X dimension of
10 mils when printed at 12 points.
- FNC1, Application Identifiers and Element Strings:

Every GS1-128 barcode begins with a Start C character followed by a (FNC1)
"Function Code One" and an
Application Identifier (AI) number. The AI defines a specific purpose for
the data field after it. The the combination of a the AI and its data field is
referred to as the element string. The AI is represented with parentheses around it.
GS1-128 compliant barcodes are generated in IDAutomation Code-128 products when
the following are true:
- Parentheses are included around the first AI in the DatatoEncode property.
- The
ApplyTilde
or process tilde option is enabled.
- The Code-128 encoding mode is set to Auto, which is the default in most
cases.
- Multiple element strings may also be encoded according to
GS-1 specifications. Variable element strings should be encoded last in the
symbol and FNC1 characters must be encoded between two or more variable length
element strings.
For testing purposes, GS1-128 symbols may be generated with the
Free
Online Barcode Creator or from the bcgen.com command line,
for example:
http://bcgen.com/demo/linear-dbgs.aspx?D=(01)10614141543219&PT=T
If it is not convenient to use parentheses to encode the FNC1 character into
the barcode, many IDAutomation products offer alternate methods. Compatibility
of these alternate methods may be verified by referencing the documentation for
that particular product.
- The Tilde Method supports the inclusion of the AI as a tilde command
when
ApplyTilde is enabled. When using this method,
the parentheses are not included in the data encoded; instead
the tilde character plus 3 digits are used to represent the
AI. Use the following extended ASCII character as the FNC1 for
the correct number of digits in the AI:
~212 = 2 digit AI
~213 = 3 digit AI
~214 = 4 digit AI
~215 = 5 digit AI
~216 = 6 digit AI
~217 = 7 digit AI
Example: to encode (8100)712345(21)12345678 with the
Tilde Method, ~2148100712345~2122112345678
would be used. Additional examples are included in
Fig 1.
- The Direct ASCII Method is somewhat easier to implement, however, there are
compatibility
limitations. Several IDAutomation products support the inclusion
of the AI with ASCII 202 (the Ê
character) in Code 128 auto. When using this method,
ApplyTilde does not have to be enabled and the parentheses
are not included in the data encoded. To make the human-readable
digits accurate, use the associated ASCII character listed below
as the FNC1 for the correct number of digits in the AI.
NOTE: The following are character examples from the 1250
ISO Latin 1 character set used in Europe & the USA. When using
the MAC or systems outside of the USA, the appropriate character
must be used that represents the proper ASCII location. When
in doubt, use the Tilde Method.
ASCII212: Ô = 2 digits
ASCII213: Õ = 3 digits ASCII214:
Ö = 4 digits
ASCII215: × = 5 digits
ASCII216: Ø = 6 digits ASCII217:
Ù = 7 digits
Example: to encode (8100)712345(21)12345678 with the
ASCII Method, Ê8100712345Ê2112345678
or Ö8100712345Ô2112345678
would be used.
ASCII
Method Compatibility Limitations: This method is not
compatible with the following:
- Web based products such as the
Online Barcode Generator,
Barcode
Server for IIS,
Web
Server Control and
Java Servlet.
- Systems that are not operating in the 1250 ISO Latin
1 character set used in Europe & the USA. When using systems
outside of the USA, the appropriate character must be used
that represents the proper ASCII location.
- MAC systems and FileMaker products; because they use
the MAC Roman character set.
- Symbol Size Reduction:
The methods represented above insert FNC1 codes into the symbol.
If symbol size needs to be minimized, multiple AIs may be included
in a single barcode without encoding additional FNC1 codes,
provided that variable length AIs are included last. The
parentheses may not correctly appear in the text interpretation
of the symbol when using this method of encoding, however they
may be easily included by inserting a custom text field below
the symbol if required.
- FNC2:
The FNC2 character may be inserted as ASCII 197 in IDAutomation
barcode products, for example: ~19780-128-4991
encodes [FNC2]80-128-4991. The IDAutomation
SC5USB Barcode Scanner may be programmed to hold the barcode
starting with the FNC2 in memory and only transmit data after scanning
a second barcode, which allows a continuous text string to be encoded
in two barcodes.
- MOD 10 Check Digits:
A GS1 MOD 10 check digit is often required when implementing
GS1-128 barcodes for various specifications; the AI is usually not
included in the MOD 10 calculation. If a MOD 10 check digit is needed,
it may be either pre-calculated, or calculated in the barcode component
at the time it is created. To enable IDAutomation barcode products
to calculate the MOD 10 when the barcode is created, the
ApplyTilde property must be enabled and the format
~m??
must be used where ?? is a 2 digit
number representing the number of characters preceding the tilde
on which to base the Mod 10 calculation. For example, entering the
data of ~2140000801234999999999~m17
creates a barcode encoding the FNC1 character followed by an AI
of (00) and the number of 008012349999999997. This MOD 10 calculation
may be checked online with the
IDAutomation
Online Barcode Font Encoder by entering the number of 00801234999999999
in the "Data To Encode" field and choosing the "MOD 10" option.
GS1 also offers an
online check digit calculator with manual calculation examples.
SSCC-18 Barcode
|
SSCC-18 Barcode |
| Desired result: |
[FNC1]0000801234999999999[MOD10] |
| Text string sent to DataToEncode parameter: |
(00)00801234999999999~m17 |
| Human readable text: |
(00) 008012349999999997 |
| Data scanned
from barcode:* |
]C100008012349999999997 |
GTIN
|
Global Trade Item Number (GTIN) |
| Desired result: |
[FNC1]013001234567890[MOD10] |
| Text string sent to DataToEncode: |
(01)3001234567890~m13 |
| Human readable text: |
(01) 30012345678906 |
| Data scanned
from barcode:* |
]C10130012345678906 |
Additional Examples:
Coupon with Expiration Date
|
Coupon Extended Code (Offer Code
and Expiration Date) |
| Desired result: |
[FNC1]81010123450901 |
| DataToEncode: |
~21481010123450901 |
| Human readable Text: |
(8101) 0123450901 |
Coupon with Household ID
|
Coupon Extended Code (Offer Code
and Household ID) |
| Desired result: |
[FNC1]81007123452112345678 |
| DataToEncode: |
~2148100712345~2122112345678
(Tilde Method) |
| Human readable text: |
(8100) 712345 (21) 12345678 |
Encoding two Variable Element Strings
|
FNC1 Inserted Between Two Element
Strings |
| Desired result: |
[FNC1]10345678[FNC1]213456789012 |
| DataToEncode: |
(10)10345678(21)213456789012 |
| Human readable text: |
(10)10345678(21)213456789012 |
To obtain more information about the formatting and placement of
GS1-128 barcodes, contact GS1.ORG.
* Many barcode scanners do not decode FNC1 codes. However,
when the "format" option of the
IDAutomation SC5USB Barcode Scanner is set to "UCC/EAN-128," FNC1
codes are decoded as ]C1 for the
first FNC1 and
ASCII 29
(The <GS> character) for additional FNC1
codes as required by GS1. IDAutomation's
Barcode Scanner
ASCII String Decoder may be used to view the <GS> character.
Most scanners with built-in decoders do not decode FNC1 codes in
GS1-128 (UCC/EAN-128) barcodes. However, when the "format" option of
the
IDAutomation SC5USB Barcode Scanner is set to "UCC/EAN-128," the
scanner decodes FNC1
AI codes according to the UCC/EAN Application Identifier Standard.
According to this standard, the first FNC1 should be translated to the
three text characters of ]C1, and
next FNC1 codes should be translated to a field separator
ASCII code 29
(The <GS> character) as demonstrated in
Fig. 2.
* The <GS> character is a group separator
function, which is
ASCII value
29. This character cannot be viewed or printed and therefore it may
not appear to be present, unless an application is used such as IDAutomation's
Barcode Scanner
ASCII String Decoder. If the
SC5 USB Barcode Scanner is being used, the GS character can be reassigned
to any ASCII character by changing the "field separator code" referred
to in the manual. For example, this may be changed to the "|" character
to make troubleshooting easier. After making that change, the scanner
would decode the symbol in Fig. 2 as follows:
]C18100712345|2112345678.
To program this change with the
SC5 USB Barcode Scanner, perform the following:
- On the Code 128 programming page, scan Program.
- Scan Field Separator Code.
- Field separator codes are programmed into the scanner as a hexadecimal
BASE-16 number. The pipe character "|" is
ASCII
7C. From the Manual's flip out page, scan 7, scan C
and scan Finish.
- On the Code 128 page, scan Exit.
The United States Postal Service (USPS) uses Code 128 barcodes for
many special services such as delivery confirmation; which is formatted
as follows:
- Start C character
- FNC1 character
- 2 digit AI (Application Identifier, which is usually 91)
- 2 digit service code
- 9 digit customer ID
- 8 digit sequential package ID
- Mod 10 check digit
- Mod 103 symbology check digit
- Stop character
The start, stop and mod 103 check digits are automatically added
in all of IDAutomation barcode products. To create the required Code128
barcode, use Code 128 Auto with ApplyTilde enabled and add in the appropriate
ASCII 202 and AI’s (as documented in the
GS1-128 section of this FAQ). A
MOD 10 Check Digit
is also required at the end of the data encoded. This may be easily
generated in IDAutomation products with the ~m
command as demonstrated in Fig 3.
When printed at 16 points, the IDAutomationC128L font will produce
the exact dimensions for GS1-128 (UCC/EAN
Code128) required by the USPS special services, which is a height of
.75" and an X dimension of .013". For more information, refer to the
USPS specifications.
More information about formatting GS1-128 barcodes with IDAutomation
products is provided in the GS1-128 section
of this FAQ.
Fig. 3: Example of Encoding USPS Barcodes
In the example below, the ASCII 202 character (Ê) may be used in
place of ~??? for products that do not
support
ApplyTilde.
|
USPS Compliant GS1-128 (UCC/EAN) for
Special Services |
| Desired result: |
[FNC1]420 12345[FNC1]91
01 123456789 12345678[MOD10] |
| Text string sent to DataToEncode: |
~21342012345~212910112345678912345678~m29 |
| Human readable text (not generated automatically): |
(420) 12345 (91) 01123456789123456789 |
| Data scanned from
barcode:* |
]C1420123459101123456789123456789 |
* USPS Characters Below the Barcode
The human-readable characters below the barcode may be easily generated
with IDAutomation products by utilizing the SpliceText option with the
Sans Serif Bold or equivalent type font.
In the event the human-readable characters below the barcode need
to be created from code, the Sans Serif Bold font should be used and
spaces should be inserted between every 4 digits. The following Visual
Basic VBA code accomplishes this purpose:
Mid(DataToEncode, 1, 4) & " " & Mid(DataToEncode,
5, 4) & " " & Mid(DataToEncode, 9, 4) & " " & Mid(DataToEncode, 13,
4) & " " & Mid(DataToEncode, 17, 4) & " " & Mid(DataToEncode, 21, 2)
Several other combinations are possible. For more information, refer
to the USPS barcode
specifications. The USPS has also standardized a newer
4-state barcode type defined as the
Intelligent Mail Barcode, which encodes delivery and tracking information
in a single symbol.
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 A |
Code B |
Code C |
ASCII * |
Unicode * |
Char |
Value |
Code A |
Code B |
Code C |
ASCII * |
Unicode * |
Char |
Value |
| Space |
Space |
00 |
0194 |
00C2 |
 |
00 |
V |
V |
54 |
0086 |
0056 |
V |
54 |
| ! |
! |
01 |
0033 |
0021 |
! |
01 |
W |
W |
55 |
0087 |
0057 |
W |
55 |
| " |
" |
02 |
0034 |
0022 |
" |
02 |
X |
X |
56 |
0088 |
0058 |
X |
56 |
| # |
# |
03 |
0035 |
0023 |
# |
03 |
Y |
Y |
57 |
0089 |
0059 |
Y |
57 |
| $ |
$ |
04 |
0036 |
0024 |
$ |
04 |
Z |
Z |
58 |
0090 |
005A |
Z |
58 |
| % |
% |
05 |
0037 |
0025 |
% |
05 |
[ |
[ |
59 |
0091 |
005B |
[ |
59 |
| & |
& |
06 |
0038 |
0026 |
& |
06 |
\ |
\ |
60 |
0092 |
005C |
\ |
60 |
| ' |
' |
07 |
0039 |
0027 |
' |
07 |
] |
] |
61 |
0093 |
005D |
] |
61 |
| ( |
( |
08 |
0040 |
0028 |
( |
08 |
^ |
^ |
62 |
0094 |
005E |
^ |
62 |
| ) |
) |
09 |
0041 |
0029 |
) |
09 |
_ |
_ |
63 |
0095 |
005F |
_ |
63 |
| * |
* |
10 |
0042 |
002A |
* |
10 |
nul |
` |
64 |
0096 |
0060 |
` |
64 |
| + |
+ |
11 |
0043 |
002B |
+ |
11 |
soh |
a |
65 |
0097 |
0061 |
a |
65 |
| , |
, |
12 |
0044 |
002C |
, |
12 |
stx |
b |
66 |
0098 |
0062 |
b |
66 |
| - |
- |
13 |
0045 |
002D |
- |
13 |
etx |
c |
67 |
0099 |
0063 |
c |
67 |
| . |
. |
14 |
0046 |
002E |
. |
14 |
eot |
d |
68 |
0100 |
0064 |
d |
68 |
| / |
/ |
15 |
0047 |
002F |
/ |
15 |
eno |
e |
69 |
0101 |
0065 |
e |
69 |
| 0 |
0 |
16 |
0048 |
0030 |
0 |
16 |
ack |
f |
70 |
0102 |
0066 |
f |
70 |
| 1 |
1 |
17 |
0049 |
0031 |
1 |
17 |
bel |
g |
71 |
0103 |
0067 |
g |
71 |
| 2 |
2 |
18 |
0050 |
0032 |
2 |
18 |
bs |
h |
72 |
0104 |
0068 |
h |
72 |
| 3 |
3 |
19 |
0051 |
0033 |
3 |
19 |
ht |
i |
73 |
0105 |
0069 |
i |
73 |
| 4 |
4 |
20 |
0052 |
0034 |
4 |
20 |
lf |
j |
74 |
0106 |
006A |
j |
74 |
| 5 |
5 |
21 |
0053 |
0035 |
5 |
21 |
vt |
k |
75 |
0107 |
006B |
k |
75 |
| 6 |
6 |
22 |
0054 |
0036 |
6 |
22 |
ff |
l |
76 |
0108 |
006C |
l |
76 |
| 7 |
7 |
23 |
0055 |
0037 |
7 |
23 |
cr |
m |
77 |
0109 |
006D |
m |
77 |
| 8 |
8 |
24 |
0056 |
0038 |
8 |
24 |
s0 |
n |
78 |
0110 |
006E |
n |
78 |
| 9 |
9 |
25 |
0057 |
0039 |
9 |
25 |
s1 |
o |
79 |
0111 |
006F |
o |
79 |
| : |
: |
26 |
0058 |
003A |
: |
26 |
dle |
p |
80 |
0112 |
0070 |
p |
80 |
| ; |
; |
27 |
0059 |
003B |
; |
27 |
dc1 |
q |
81 |
0113 |
0071 |
q |
81 |
| < |
< |
28 |
0060 |
003C |
< |
28 |
dc2 |
r |
82 |
0114 |
0072 |
r |
82 |
| = |
= |
29 |
0061 |
003D |
= |
29 |
dc3 |
s |
83 |
0115 |
0073 |
s |
83 |
| > |
> |
30 |
0062 |
003E |
> |
30 |
dc4 |
t |
84 |
0116 |
0074 |
t |
84 |
| ? |
? |
31 |
0063 |
003F |
? |
31 |
nak |
u |
85 |
0117 |
0075 |
u |
85 |
| @ |
@ |
32 |
0064 |
0040 |
@ |
32 |
syn |
v |
86 |
0118 |
0076 |
v |
86 |
| A |
A |
33 |
0065 |
0041 |
A |
33 |
etb |
w |
87 |
0119 |
0077 |
w |
87 |
| B |
B |
34 |
0066 |
0042 |
B |
34 |
can |
x |
88 |
0120 |
0078 |
x |
88 |
| C |
C |
35 |
0067 |
0043 |
C |
35 |
em |
y |
89 |
0121 |
0079 |
y |
89 |
| D |
D |
36 |
0068 |
0044 |
D |
36 |
sub |
z |
90 |
0122 |
007A |
z |
90 |
| E |
E |
37 |
0069 |
0045 |
E |
37 |
esc |
{ |
91 |
0123 |
007B |
{ |
91 |
| F |
F |
38 |
0070 |
0046 |
F |
38 |
fs |
| |
92 |
0124 |
007C |
| |
92 |
| G |
G |
39 |
0071 |
0047 |
G |
39 |
gs |
} |
93 |
0125 |
007D |
} |
93 |
| H |
H |
40 |
0072 |
0048 |
H |
40 |
rs |
~ |
94 |
0126 |
007E |
~ |
94 |
| I |
I |
41 |
0073 |
0049 |
I |
41 |
us |
del |
95 |
0195 |
00C3 |
à |
95 |
| J |
J |
42 |
0074 |
004A |
J |
42 |
fnc 3 |
fnc 3 |
96 |
0196 |
00C4 |
Ä |
96 |
| K |
K |
43 |
0075 |
004B |
K |
43 |
fnc 2 |
fnc2 |
97 |
0197 |
00C5 |
Å |
97 |
| L |
L |
44 |
0076 |
004C |
L |
44 |
Shift |
Shift |
98 |
0198 |
00C6 |
Æ |
98 |
| M |
M |
45 |
0077 |
004D |
M |
45 |
code C |
code C |
99 |
0199 |
00C7 |
Ç |
99 |
| N |
N |
46 |
0078 |
004E |
N |
46 |
code B |
fnc 4 |
code B |
0200 |
00C8 |
È |
100 |
| O |
O |
47 |
0079 |
004F |
O |
47 |
fnc 4 |
code A |
code A |
0201 |
00C9 |
É |
101 |
| P |
P |
48 |
0080 |
0050 |
P |
48 |
fnc 1 |
fnc 1 |
fnc 1 |
0202 |
00CA |
Ê |
102 |
| Q |
Q |
49 |
0081 |
0051 |
Q |
49 |
Start A |
Start A |
Start A |
0203 |
00CB |
Ë |
103 |
| R |
R |
50 |
0082 |
0052 |
R |
50 |
Start B |
Start B |
Start B |
0204 |
00CC |
Ì |
104 |
| S |
S |
51 |
0083 |
0053 |
S |
51 |
Start C |
Start C |
Start C |
0205 |
00CD |
Í |
105 |
| T |
T |
52 |
0084 |
0054 |
T |
52 |
Stop |
Stop |
Stop |
0206 |
00CE |
Î |
na |
| U |
U |
53 |
0085 |
0055 |
U |
53 |
|
|
|
|
|
|
|
* 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 Macintosh, 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 |
STOP |
| 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.
- 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 C |
66 |
73 |
90 |
STOP |
| weighting |
|
1 |
2 |
3 |
|
| values |
105 |
66 |
73 |
90 |
|
| totals |
105 |
66 |
146 |
270 |
|
- Separate the numbers into pairs and choose the appropriate character
from the character set table
that represents the number pair.
- Calculate the Total: 105 + (66*1) + (73*2) + (90*3) =
587
- 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.
- 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 B |
b |
i |
z |
É |
m |
STOP |
| weighting |
|
1 |
2 |
3 |
4 |
5 |
|
| values |
104 |
66 |
73 |
90 |
101 |
77 |
|
| totals |
104 |
66 |
146 |
270 |
404 |
385 |
|
- Calculate the Total: 104 + (66*1) + (73*2) + (90*3) +
(101*4) + (77*5) = 1375
- 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 Macintosh 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
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. The Code 128 font may be printed as small as
4 points if the scanner is capable reading it. IDAutomation's Code 128
fonts are reliably read with the
IDAutomation
USB Barcode Scanner at point sizes of 6 to 48 points.
| 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 |
Eighteen different versions of the Code 128 barcode
fonts are provided to support human readable versions and different
width and height requirements. Fonts with the letter "H" in the font
name are human-readable versions. The last
characters in the Code 128 barcode font name determine the height of
the barcode with the shortest being "XS" and the tallest being
"XXL". Because each single font may be printed at various point
sizes, there are several combinations of heights and widths that may
be produced.
| Purchased Font Name |
Evaluation Font Name* |
Font Height at 12pts* |
|
Code 128 Fonts (no text below
barcode) |
| IDAutomationC128XXS |
IDAutomationSC128XXS |
.10" or .254 CM |
| IDAutomationC128XS |
IDAutomationSC128XS |
.20" or .508 CM |
| IDAutomationC128S |
IDAutomationSC128S |
.35" or .889 CM |
| IDAutomationC128M |
IDAutomationSC128M |
.50" or 1.27 CM |
| IDAutomationC128L |
IDAutomationSC128L |
.60" or 1.46 CM |
| IDAutomationC128XL |
IDAutomationSC128XL |
.75" or 1.90 CM |
| IDAutomationC128XXL |
IDAutomationSC128XXL |
1" or 2.54 CM |
| Code 128 Fonts "Character set B" (text below barcode:**) |
| IDAutomationHbC128XS |
NA |
.20" or .508 CM |
| IDAutomationHbC128S |
NA |
.35" or .889 CM |
| IDAutomationHbC128M |
IDAutomationSHbC128M |
.50" or 1.27 CM |
| IDAutomationHbC128L |
NA |
.60" or 1.46 CM |
| IDAutomationHbC128XL |
NA |
.75" or 1.90 CM |
| IDAutomationHbC128XXL |
NA |
1" or 2.54 CM |
| Code 128 Fonts "Character set C" (text below barcode:**) |
| IDAutomationHcC128XS |
NA |
.20" or .508 CM |
| IDAutomationHcC128S |
NA |
.35" or .889 CM |
| IDAutomationHcC128M |
IDAutomationSHcC128M |
.50" or 1.27 CM |
| IDAutomationHcC128L |
NA |
.60" or 1.46 CM |
| IDAutomationHcC128XL |
NA |
.75" or 1.90 CM |
| IDAutomationHcC128XXL |
NA |
1" or 2.54 CM |
| * Measurements are approximate and
were measured when printed at 12 points, which should work for
most scanners. Measurements for Human Readable fonts do not
include the text below.
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 human-readable versions
also work with IDAutomation's font encoder tools. However, they are
not normally used because the Code 128 symbology MOD103 check
digit is usually displayed in the result. Human readable versions
are often used for testing purposes or when it is not a problem
to have the symbology check digit displayed. To print the human-readable
data without the check digit, use the fonts beginning in IDAutomationC128
and print the data encoded as text below or above the barcode.
The XXS size is not available in the human readable versions
because of size limitations.
|
| Purchased Font Name |
Evaluation Font
Name* |
Font
Height at 12pts* |
| Code
128 Fonts (no text below barcode) |
| AdvC128a |
sAdC128a |
1/16" (.078") or .2 cm |
| AdvC128b |
sAdC128b |
1/8" (.125") or .4 cm |
| AdvC128c |
sAdC128c |
1/4" (.25") or .6 cm |
| AdvC128d |
sAdC128d |
1/2" (.5") or 1.1 cm |
| AdvC128e |
sAdC128e |
5/8" (.625") or 1.6 cm |
| AdvC128f |
sAdC128f |
1" or 2.5 cm |
| Code
128 Fonts "Character set B" (text below the barcode:**) |
| C128bHa |
NA |
1/16" (.078") or .2 cm |
| C128bHb |
NA |
1/8" (.125") or .4 cm |
| C128bHc |
sC128bHc |
1/4" (.25") or .6 cm |
| C128bHd |
NA |
1/2" (.5") or 1.1 cm |
| C128bHe |
NA |
5/8" (.625") or 1.6 cm |
| C128bHf |
NA |
1" or 2.5 cm |
| Code
128 Fonts "Character set C" (text below barcode:**) |
| C128cHa |
NA |
1/16" (.078") or .2 cm |
| C128cHb |
NA |
1/8" (.125") or .4 cm |
| C128cHc |
sC128cHc |
1/4" (.25") or .6 cm |
| C128cHd |
NA |
1/2" (.5") or 1.1 cm |
| C128cHe |
NA |
5/8" (.625") or 1.6 cm |
| C128cHf |
NA |
1" or 2.5 cm |
If assistance is needed, please
contact IDAutomation.
Back to Top
|