This article explains the details of code 128 symbology.
|This article provide multiple formats:|
HTML version online address:
Any question or bug report are encouraged to post in the discussion group:
Copyright © 2012 Crifan, http://crifan.com
This article conform to:Attribution-NonCommercial 2.5 Generic (CC BY-NC 2.5)
Table of Contents
List of Figures
List of Tables
For the value column in Table 3.1, “Encoding Code Table”, the “value” is also called code, or character, or digit.
Start code = start character
Check character = check digit
Function code = function character
The variant is just the character set, so variant A/B/C is just the Character Set A/B/C
This item means the symboloy for UCC 128 or EAN 128, often can be write like this:
UCC-128 or EAN-128, UCC/EAN-128, UCC.EAN 128, ......
It is just a variant of Code 128.
More please refer to Section 2.8, “Other related info”
Code 128 is a variable length, high density, alphanumeric symbology.
It is a very effective, high-density symbology which encoding of alphanumeric data.
high-density: the high density means: when encoding the numeric data, then using Code set C, which using one code to represent two digital data. While normally using one code represent one digit/data.
Code 128 also employs a check digit for data security.
Code 128 symbology must include a checksum digit.
Code 128 has three characters Set: A, B, C.
Code 128 has 106 different bar and space patterns and each pattern can have one of three different meanings, depending on which of three different character sets (characters Set A/B/ C) is employed.
Three different start characters tell the reader the character set used in the following encoding, and three shift codes permits changing character set inside the symbol.
So, sometime you can see some item like this:
Table of Contents
As you can see in Table 3.1, “Encoding Code Table”
The three start characters are:
"START A"=103, "START B"=104, "START C"=105
As you can see in Table 3.1, “Encoding Code Table”, three CODEs are: "Code A", "Code B", "Code C".
Within a symbol, one can shift between code sets by using the special character CODE and SHIFT.
The CODE character shifts the code for all subsequent characters to the specified code set.
The SHIFT character just changes the next character and only changes between Code Set A and Code Set B or the reverse.
So, within the data in Code 128, changes to other character Set:
For character set A: change to character set B is "Code B=100", to character set C is "Code C=99"
For character set B: change to character set A is "Code A=101", to character set C is "Code A=99"
For character set C: change to character set A is "Code B=101", to character set C is "Code B=100"
The example of changing to Character Set C in Character Set A using 99 = "Code C", can be found in later Section 2.5, “Calculate the Check/Checksum Digit”.
Character Set A: encodes all upper case ('A=33' to 'Z=58') and ASCII control characters ('NUL=64' to 'US=95');
Character Set B: encodes all upper ('A=33' to 'Z=58') and lower ('a=65' to 'z=90') case characters;
Character Set C: encodes numeric digit pairs 00 through 99 ('00=00' to '99=99').
Character Set A and B: used to encode alpha-numeric information
Character Set C : offers double density when being used to encode numeric data, which means use a single value/code, decoded as two digital value/data, that is one value = two data.
This third character set - Character Set C, effectively doubles the code density when printing numeric data.
In addition to ASCII characters, Code 128 also allows encoding of four special function codes (FNC1 - FNC4), which are listed in Table 3.1, “Encoding Code Table”.
The meaning of function code FNC1 and FNC4 were originally left open for application specific purposes.
Recently an agreement was made by the Automatic Identification Manufacturers Assoc. (AIM) and the European Article Numbering Assoc. (EAN) to reserve FNC1 for use in EAN applications.
FNC1 at the beginning of a bar code indicates that it begins with a 2- 3- or 4-digit application identifier assigned by the Uniform Code Council, which explains the following digits. For example, application identifier 421 indicates that an ISO 3166-1 numeric country code and ship-to postal code follows.
For example, the U.S. ZIP code for the White House would generally be printed as "(421) 840 20500", but would actually be coded as "[Start C] [FNC1] 42 18 40 20 50 [Code A] 0 [Check symbol 80] [Stop]"
|The FNC1 for the UCC/EAN-128|
The function 1 (FNC 1), which follows the start character, enables scanners and processing software to auto-discriminate between UCC/EAN-128 and other barcode symbologies, and subsequently only process relevant data.
FNC2 is used to instruct a bar code reader to concatenate the message in a bar code symbol with the message in the next symbol.
FNC3 is used to instruct a bar code reader to perform a reset. When FNC3 is encoded anywhere in a symbol, any data also contained in the symbol is discarded.
Before a Code 128 symbol may be encoded, the software must compute the correct checksum digit which will be included in the bar code. The checksum digit is based on Modulus 103 Checksum based on the weighted sum of the values of each of the digits in the message that is being encoded, including the start character.
The steps for calculating the check digit are as follows:
This is easier to understand with an example.
Let's calculate the checksum digit for the sample bar code above, "HI345678".
The checksum digit is included in all Code 128 bar codes, but it isn't printed as part of the text below the bar code symbol (as is the case with UPC and EAN symbols).
Table 2.1. Calculate checksum digit of "HI345678"
|Calculation||103||40 * 1||41 * 2||99 * 3||34 * 4||56 * 5||78 * 6|
Summing up the running checksum for each digit, we get:
103 + 40 + 82 + 297 + 136 + 280 + 468 = 1406
1046 MOD 13 = the remainder of 1406 / 103 = 67
Thus the checksum digit is the character which has a value of 67.
Table 2.2. Structure of Code 128
|one of three start codes
"START "=103, or
|the data itself||a check character||a stop character||Termination bar of 11|
We will now code the above example, HI345678, in Code 128. As we calculated in the Checksum Digit Calculation section, the checksum digit is 67. So we must also code the checksum digit at the end of the message.
We encode each digit using the encoding table above:
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.
Also others describe the structure Code 128 like this:
Table 2.3. Structure of Code 128 with quiet zone
Then this picture illuminates it well:
For Code 39, Code 93, Code 128, EAN /UCC 128:
There are all variable length alphanumeric symbology.
And their "Data Capacity" - the practical upper limit, dependent on the scanner and is typically between 20 and 40 characters.
Code 128 is more efficient at encoding data than Code 39 or Code 93.
Code 128 is the best choice for most general bar code applications.
Code 39 and Code 128 are both very widely used while Code 93 is rarely used.
Table of Contents
This table indicates how to encode each digit of a Code 128 bar code.
Note that it is easiest to think of each character as a value between 0 and 105, inclusive, rather than thinking of them as characters.
The character that a value represents depends on what mode (or character set) you're in-so rather than thinking of a character as "A" or "B", etc. it is more appropriate to think of it as 33, 34, etc.
Table 3.1. Encoding Code Table
|VALUE||WHICH REPRESENTS IN CHARACTER SET||ENCODING||VALUE||WHICH REPRESENTS IN CHARACTER SET||ENCODING|
|46||N||N||46||10111000110||99||Code C||Code C||99||10111011110|
|47||O||O||47||10001110110||100||Code B||FNC4||Code B||10111101110|
|48||P||P||48||11101110110||101||FNC4||Code A||Code A||11101011110|
|50||R||R||50||11000101110||103||START A||START A||START A||11010000100|
|51||S||S||51||11011101000||104||START B||START B||START B||11010010000|
|52||T||T||52||11011100010||105||START C||START C||START C||11010011100|
There are three type special values: