Universal Product Code - Encoding

Encoding

The UPC-A barcode is an optical pattern of bars and spaces that format and encode the UPC digit string. Each digit is represented by a unique pattern of two bars and two spaces. The bars and spaces are variable width; they may be 1, 2, 3, or 4 units (modules) wide. The total width for a digit is always 7 modules. To represent the 12 digits of the UPC-A code requires a total of 7×12 = 84 modules.

A complete UPC-A includes 95 modules: the 84 modules for the digits (L and R) combined with 11 modules for the start, middle, and end (S, M, and E) patterns. The S and E patterns are 3 modules wide and use the pattern bar-space-bar; each bar and space is one module wide. The M pattern is 5 modules wide and uses the pattern space-bar-space-bar-space; each bar and space is one module wide. In addition, a UPC symbol requires a quiet zone (additional space modules) before the S pattern and another quiet zone after the E pattern.

Quiet
Zone
Start Left Numerical Digits Middle Right Numerical Digits End Quiet
Zone
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9

Numbers on the right side of the middle guard bars are optically the inverse of the numbers to the left. In other words, while a number on the left side of the UPC will be made up of black bars and white spaces, the same number on the right side would be indicated by the inverse (what was black on the left is now white and what was white is now black). This inversion enables the bar code to be scanned from left-to-right or right-to-left. Left-side digits consist of an even number of white spaces and an odd number of black bars. Right side digits are the opposite. Using this difference, the scanning software knows if it read the code the correct way or upside down. In the illustration above, the "4" digit (shown in detail) is bar × 1, space × 1, bar × 3, space × 2. If the "4" digit were on the left hand side it would be space × 1, bar × 1, space × 3, bar × 2.

Read more about this topic:  Universal Product Code