Code 128 is a very high density alphanumeric bar code. The symbol can be as long as necessary to store the encoded data. It is designed to encode all 128 ASCII characters, and will use the least amount of space for data of 6 characters or more of any 1-D symbology.
Each data character encoded in a Code 128 symbol is made up of 11 black or white modules. The stop character, however, is made up of 13 modules. Three bars and three spaces are formed out of these 11 modules. Bar and spaces can vary between 1 and 4 modules wide.
The symbol includes a quiet zone (10 x-dimensions), a start character, the encoded data, a check character, the stop character, and a trailing quiet zone (10 x-dimensions).
There are 107 different 3 bar/3 space combinations. Each of the 107 combinations can be assigned one of three different character set meanings. These meanings are set by using one of three different start characters. Start Code A allows encoding all the standard alphanumeric keyboard characters plus control characters and special characters. Start Code B includes all standard alphanumeric keyboard characters plus lower case alpha and special characters. Start Code C includes a set of 100 digit pairs from 00 to 99 and can be used to double the density of encoding numeric-only data.
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.
Each character has a value ranging from 0 to 105. This value is used to calculate the check character for each symbol.
The check character is a Modulus 103 Checksum that is calculated by summing the start code value plus the product of each character position (most significant character position equals 1) and the character value of the character at that position. This sum is divided by 103. The remainder of the answer is the value of the Check Character (which can be looked up from the table). Every encoded character is included except the Stop and Check Character.
| Example |
Example: BarCode 1
Message : Start B B a r C o d e 1
Value 104 34 65 82 35 79 68 69 0 17
Position: - 1 2 3 4 5 6 7 8 9
Calculate Total: 104 + (34x1) + (65x2) + (82x3) + (35x4) + (79x5) +
(68x6) + (69x7) + (0x8) + (17x9) = 2093
2093/103 = 20 remainder 33
33 = A
Final message: (Start B)BarCode 1(A)(STOP) |
 |
Summary
- The width of a slim bar is called the module.
- There are bars of 1, 2, 3 or 4 modules; equally for the
spaces.
- There are 107 combinations, each is coded with 11 modules including 3 bars and 3 spaces (The STOP pattern has 4 bars).
- There are 3 tables giving the character or the function for each pattern.
*
Table A contains the capital letters, the digits, the
punctuations, some control codes and special codes.
* Table B
contains capital and lower case letters, the digits, the punctuation marks
and special codes.
* Table C contains pairs of digits
(giving the ability to double the density) and special codes.
- Quiet zones of at least 10 modules are found on the left and
on the right of the code.
- There is a START character at the beginning of the code. There
are 3 START characters fixing the table used for the start.
- The code ends with a STOP character.
- Some special characters (99, 100 and 101) make it possible
to pass from one table to another; the SHIFT character (98) switches
the next character between tables A and B.
- A checksum must be added; its value is calculated by adding up
the value of the START then the value of each pattern multiplied by its
row; then by taking the remainder of the division of this sum by 103.
- In the table below a bar module is symbolized by '1' and a space module by '0'.
- The columns "ASCII Code" and "Character"
indicate the place of the patterns in the code128 font
- The character no. 0 (Space) is obtained with the code 32 or with the code 207 because some programming tools cannot use code 32.