Introduction

Structure of an EAN barcode
An EAN-13 number consists of four areas: ¤ The Number System
¤ The Manufacturer Code
¤ The Product Code
¤ The Check Digit
Normally the number system digit is printed to the left of the barcode, and the check digit to the right. The manufacturer and product codes are printed just below the barcode, separated by the guard bar.
¤ Number System
The number system consists of two digits (sometimes three digits) which identify the country/region numbering authority which assigned the manufacturer code. Any number system which starts with the digit 0 is a UPC-A barcode. The number system list is maintained by EAN organization (www.ean-int.org). Also, the number system for every country/region are listed here.
¤ The Manufacturer Code
The manufacturer code is a unique code assigned to each manufacturer by the numbering authority indicated by the number system code. All products produced by a given company will use the same manufacturer code.
EAN uses what is called "variable-length manufacturer codes." Assigning fixed-length 5-digit manufacturer codes, as the UCC has done until recently, means that each manufacturer can have up to 99,999 product codes--and many manufacturers don't have that many products, which means hundreds or even thousands of potential product codes are being wasted on manufacturers that only have a few products. Thus if a potential manufacturer knows that it is only going to produce a few products, EAN may issue it a longer manufacturer code, leaving less space for the product code. This results in more efficient use of the available manufacturer and product codes.
¤ The Product Code
The product code is assigned by the manufacturer. The product code immediately follows manufacturer code. The total length of manufacturer code plus product code must be exact 10 digits.
¤ The Check Digit
The check digit is used to verify that the barcode is generated or scanned correctly. The check digit is calculated based on the rest of the barcode digits.
Since a scan can produce incorrect data due to inconsistent scanning speed, print imperfections, or a host of other problems, it is useful to verify that the rest of the data in the barcode has been correctly interpreted.
The nominal X dimension is 13 mils. The printable X dimension ranges from 10.4 to 24 mils.
The method of calculating the check digit:
1. From the right to left, start with odd position, assign the odd/even position to each digit.
2. Sum all digits in odd position and multiply the result by 3.
3. Sum all digits in even position.
5. Sum the results of step 3 and step 4.
6 .Divide the result of step 4 by 10. The check digit is the number which adds the remainder to 10.
How to calculate the checksum (Visual Basic function):
Function Append_EAN_Checksum (RawString as String)
Dim Position as Integer
Dim CheckSum as Integer CheckSum = 0
For Position = 2 to 12 step 2
Checksum = Checksum + Val(Mid$(RawString, Position, 1))
Next Position
CheckSum = CheckSum * 3
For Position = 1 to 11 Step 2
CheckSum = CheckSum + Val(Mid$(RawString, Position, 1))
Next Position
CheckSum = CheckSum Mod 10
CheckSum = 10 - CheckSum
If CheckSum = 10 Then
CheckSum = 0
End If
Append_Ean_Checksum = RawString & Format$(CheckSum, "0")
End Function
Encoding
A EAN-13 symbol can be divided into two halves, each consisting of six digits
separated by a center guard bar pattern. The whole symbol
is surrounded by two guard bar patterns. The same digit has
different encoding depends whether it is in the left halve
or in the right halve. The encoding pattern for digits in
the left halve always starts with a space while the one for
digits in the right halve always start with a bar and ends
with a space.
A EAN-13 symbol has the following structure:1. Start guard bars, always with a pattern bar+space+bar.
2. Left halve, six digits encoded using the encoding schema A or B;
3. Center guard bars, with a pattern space+bar+space+bar+space.
4. Right halve, six digits encoded using the encoding schema C.
5. Stop guard bars, always with a pattern bar+space+bar.