EAN and UPC

The EAN and UPC codes are the most common retail codes and one of these is likely to be found on virtually every item in a supermarket.

The standard EAN-13 code contains 13 digits and is a superset of the UPC-A code (which contains 12 digits). Confusingly the 13th digit of the EAN code is actually the leftmost digit, and this is not encoded in bars and spaces, but in the combination of coding rules used to encode the next six digits. The UPC coding of the first six digits uses only one of the coding rules of the EAN standard. As a result, EAN and UPC codes are very similar and can be read by the same scanners.

One of the problems with this approach is that there is not a one-to-one correspondence between a digit and a pattern of bars and spaces; for example, the digit 0 may be encoded in three different patterns in an EAN symbol. The three different patterns are called Sets A, B and C. Consequently three different characters are required to represent 0 within a barcode font - the dLSoft EAN/UPC font uses A, a and 0, for set A, B and C respectively as shown in the Character sets Table below.

One of the cosmetic features of EAN and UPC symbols is that the start and stop characters, and the “centre marker” character (which merely separates the left hand six characters from the right hand six) are usually printed slightly longer than the encoded characters. The elongation of these bars has no effect on the machine readability of the symbol.

The dLSoft EAN/UPC font provides two sets of characters, one which contains just the bars and spaces and in which the start, stop and centre marker characters are the same height as the coded characters, and one set in which the barcode characters have their numeric values reproduced underneath and in which the start, stop and centre marker are elongated.

In both cases the normal start and stop characters are [ and ] respectively and the centre marker is /. For the special case of UPC-E codes the start and stop characters are { and } respectively. UPC-E does not use a centre marker.

EAN and UPC codes both require a check digit, the value of which may be obtained as follows:

Starting with the rightmost digit (excluding the check digit), find the sum of the alternate digits; multiply this sum by 3 and add to the sum of the remaining digits. The check digit is the number which when added to this result gives a multiple of 10.

The right-hand six characters in both EAN and UPC symbols are encoded using characters from Set C. The left hand six digits in UPC codes are encoded using Set A. The left-hand six digits (excluding the 13th) in EAN codes are encoded using a combination of Sets A and B - and the combination of sets is used to encode the 13th digit as follows:

 

Digit

n1

n2

n3

n4

n5

n6

0

A

A

A

A

A

A

1

A

A

B

A

B

B

2

A

A

B

B

A

B

3

A

A

B

B

B

A

4

A

B

A

A

B

B

5

A

B

B

A

A

B

6

A

B

B

B

A

A

7

A

B

A

B

A

B

8

A

B

A

B

B

A

9

A

B

B

A

B

A

 

The dFont program provided with the dLSoft Barcode fonts calculates check digits and encoding patterns for both EAN and UPC-A codes, and their minimal size relatives (EAN-8 and UPC-E), and the source code is provided and may be adapted to the users needs - for example, for automating the calculation in a spreadsheet or database.

Users wishing to use their own encoding schemes should note that the UPC-E stop character is NOT the same as UPC-A or EAN stop characters (because it needs to indicate the direction of scanning). The UPC-E stop character is provided in the dLSoft EAN/UPC fonts as }.

More:

Supplementary codes

Light margin indicators

EAN/UPC Character Sets Table