The EAN-13 barcode, which stands for 'European Article Number', is a globally used standard for marking retail goods. |
To encode the 13-digit EAN-13 number, the digits are split into 3 groups; the first digit, the first group of 6 and the last group of 6. The first group of 6 is encoded using a pattern whereby each digit has two possible encodings, one of which has even parity (denoted with letter G) and one of which has odd parity (denoted with letter L). |
The first digit is not represented directly by a pattern of bars and spaces, but is encoded indirectly, by selecting a pattern of choices between these two encodings for the first group of 6 digits, according to the table below. All digits in the last group of 6 digits are encoded using a single pattern RRRRRR, the one also used for UPC. |

|
The structure of the EAN-13 barcode is as follows: |
Basic Structure |
The EAN-13 barcode is composed of 13 digits: The first digit is the prefix. The next six digits are the manufacturer code. The following five digits are the product code. The last digit is the check digit. |
Barcode Representation |
The barcode itself consists of 95 modules (also called areas) of equal width, where each module can be either white (represented as 0) or black (represented as 1). These modules are divided into several parts: |
1.Left Guard Bars (3 modules): Start delimiter, represented as 101. 2.Left Data Characters (42 modules): Represented by six digits, each encoded with 7 modules. 3.Center Guard Bars (5 modules): Middle delimiter, represented as 01010. 4.Right Data Characters (42 modules): Represented by six digits, each encoded with 7 modules. 5.Right Guard Bars (3 modules): End delimiter, represented as 101. |

|
Detailed Module Structure |
Guard Bars Left Guard Bars (101): These are used to indicate the start of the barcode. Center Guard Bars (01010): These are used to separate the left and right halves of the barcode. Right Guard Bars (101): These are used to indicate the end of the barcode. |
Data Characters Left Data Characters: Each of the six digits on the left side can be encoded using patterns that vary depending on the first digit of the barcode. These patterns can be either: A-pattern (odd parity): Encoded with 0 representing white and 1 representing black. B-pattern (even parity): Also encoded with 0 and 1 but with a different pattern for each digit. Right Data Characters: Each of the six digits on the right side is encoded using the C-pattern (always the same pattern for each digit, irrespective of the first digit of the barcode). |

|
Encoding Patterns The encoding for each digit is different and follows specific patterns for A, B, and C. |
A-pattern (Left Side) 0: 0001101 1: 0011001 2: 0010011 3: 0111101 4: 0100011 5: 0110001 6: 0101111 7: 0111011 8: 0110111 9: 0001011 |
B-pattern (Left Side) 0: 0100111 1: 0110011 2: 0011011 3: 0100001 4: 0011101 5: 0111001 6: 0000101 7: 0010001 8: 0001001 9: 0010111 |
C-pattern (Right Side) 0: 1110010 1: 1100110 2: 1101100 3: 1000010 4: 1011100 5: 1001110 6: 1010000 7: 1000100 8: 1001000 9: 1110100 |

|
Example Breakdown |
Lets consider the EAN-13 code: 4006381333931. First Digit (4): Determines the encoding pattern for the left side digits. |
Left Side (006381): 0 (A-pattern): 0001101 0 (A-pattern): 0001101 6 (A-pattern): 0101111 3 (A-pattern): 0111101 8 (A-pattern): 0110111 1 (A-pattern): 0011001 |
Center Guard Bars: 01010 |
Right Side (333931): 3 (C-pattern): 1000010 3 (C-pattern): 1000010 3 (C-pattern): 1000010 9 (C-pattern): 1110100 3 (C-pattern): 1000010 1 (C-pattern): 1100110 |

|
Visual Representation |
Combining all the components: |
Left Guard Bars: 101 Left Data Characters: 0001101 0001101 0101111 0111101 0110111 0011001 Center Guard Bars: 01010 Right Data Characters: 1000010 1000010 1000010 1110100 1000010 1100110 Right Guard Bars: 101 |
Hence, the full barcode in binary representation would be: 101 0001101 0001101 0101111 0111101 0110111 0011001 01010 1000010 1000010 1000010 1110100 1000010 1100110 101 Conclusion |

|
This binary sequence is then translated into the visual black-and-white bars that scanners read, enabling efficient identification and tracking of products in retail environments. |