Barcodes and UPC codes
A one-dimensional, or linear, barcode is a sequence of vertical lines — bars — and spaces used to represent numbers or alphanumeric characters. In some ways, the electrical signal corresponding to a barcode’s sequence of light and dark as you scan from the start to the end of the barcode is similar to the signals you find on a serial (RS-232) data line. A barcode has a start code, the encoded data, and a stop code that corresponds to the start bit, data bits, and stop bit on a serial line.
Barcodes are also similar to serial port data in that there are message structures imposed on the raw data encoding. For barcodes, those message structures are called symbologies, and they define how much and what type of information the barcode carries. Of the many different barcode symbologies, there are two specific ones, with some variants, that you’re most likely to need to process in a home inventory application, and which our Anything Inventory software processes:
UPC — The grocery industry in the United Stated adopted the first widespread barcode, the Universal Product Code (UPC), in 1973. The most common version of UPC, called UPC-A, consists of 12 digits broken down as shown in Figure 3. Starting at the left of the number, the first digit identifies the number system code. The next five digits identify the manufacturer, using code assignments defined by the Uniform Code Council. The next five digits identify the specific product using codes assigned by the manufacturer, while the final digit is a check digit used to ensure that the barcode scanner reads the sequence correctly. There’s no necessary physical or positional correlation between the digits and the bars; the barcode scanner only sees the widths of the black and white areas, ignoring their height and any printed elements.
The UPC-E variant is a fixed-length abbreviation of UPC-A including only a total of eight digits. Six of the UPC-E digits are derived from the UPC-A code.

FIGURE 3: UPC-A structure
EAN — The European Article Numbering (EAN) standard is based on UPC (indeed, UPC is the subset of the thirteen-digit EAN-13 standard formed by eliminating the first digit). EAN is widely used outside the United States, and for some applications, such as books, in the U.S.A. The first 2 or 3 digits of the EAN-13 barcode are a country code, followed by 9 or 10 digits for the item code and a check digit. The 978 country code indicates that the item code holds 9 digits of an ISBN (International Standard Book Number). In deference to the country code terminology, 978 is often said to refer to Bookland. The ISBN check digit, completing the usual 10-digit number, is omitted, but the EAN check digit performs the same function, and the ISBN check digit is readily recomputed from the 9 digits themselves.