A reader on line one sends the MES 12 digits for a carton; the same carton on line two produces 13 digits, and the lookup fails on one of the two lines. Nothing is broken. The two payloads are the same GTIN in two conventions, and the entire difference is a leading zero. Here is why an EAN-13 that starts with 0 is physically the same symbol as a UPC-A, why readers and decode libraries report one form, and how to make every output match — by padding to 14 digits as text, or by setting the reader's emulation once. If you wire fixed code readers into PLCs, databases or MES keys, this removes a whole class of mismatch tickets.
The same bars, the same check digit
EAN-13 encodes 13 digits, and its leftmost digit is the number-system digit. GS1 assigns the prefixes starting with 0 to the North American UPC system. When that first digit is 0, the bar-and-space pattern of the EAN-13 matches the UPC-A encoding of the remaining 12 digits module for module. A scanner reads dark-light transitions, not intentions, so no reader can tell the two apart — and an EAN-13 with a leading 0 decoding as UPC-A is intended behavior, not a fault.
The check digit survives too. It is a weighted sum of the data digits, and a leading zero adds 0 to that sum whatever weight it carries. A UPC-A carries 12 digits: number-system digit, company prefix, item reference, check digit. An EAN-13 adds one number-system digit in front. One label, one GTIN, one check digit — only the length you read back differs.
Why the reader answers with 12 digits
Decoders test the UPC-A interpretation first and report a matching symbol as UPC-A. Open-source decode libraries popular in prototype code behave the same way, so your software receives 12 digits even with EAN-13 enabled. Industrial readers are configurable: the default symbology set usually transmits UPC-A without the zero, and nearly every reader's configuration utility carries per-symbology options to expand or convert the result. Two readers can therefore disagree by one character on the same label and both be correct; the disagreement is reporting convention, not decode quality. Judge a decode by its read confidence, and judge the string by the rules below.
The 14-digit rule: pad left, compare as text
GS1 defines the full GTIN as 14 digits, and every shorter carrier is left-padded with zeros to that length. One item, one key, no matter which symbol carried it:
Compare payloads only after padding, and hold the key as text. Numeric fields and spreadsheet cells delete leading zeros; a numeric input that deletes leading zeros on an HMI does the same before the PLC ever sees the string. CSV exports that strip leading zeros corrupt the archive on write for the same reason. When the number travels in a GS1 message it sits in application identifier (01) as all 14 digits; the GS1 QR FNC1 separators guide shows how that string is framed.
Worked example: one number, three carriers, one check digit
Take the test number 012345678905 — a valid UPC-A whose check digit is 5 — and weigh it three ways.
- As UPC-A, positions 1, 3, 5, 7, 9 and 11 weigh 3, the rest weigh 1: (0 + 2 + 4 + 6 + 8 + 0) × 3 = 60, plus (1 + 3 + 5 + 7 + 9) = 25, total 85. Check: 85 + 5 = 90, divisible by 10, valid.
- As EAN-13 (0012345678905), weights alternate 3, 1 from the leftmost digit: (0 + 1 + 3 + 5 + 7 + 9) × 3 = 75, plus (0 + 2 + 4 + 6 + 8 + 0) = 20, total 95. Check: 95 + 5 = 100, divisible by 10, valid.
- As GTIN-14 (00012345678905), the two leading zeros add 0 × 3 and 0 × 1, so the total is 85 again. Check: 85 + 5 = 90, valid.
Three strings — 012345678905, 0012345678905, 00012345678905 — one item, one check digit. Whichever carrier the label printer emits, the 14-digit form is the key to store and compare.
Where the missing zero bites
Three places, in the order they bite in production:
- Database keys. A table keyed on the 13-digit EAN string rejects the 12-digit read of the same carton, and the GTIN product lookup after barcode scanning returns nothing.
- PLC matching. A rung comparing fixed-length strings passes one line and fails the other; the PLC ladder logic that compares barcode strings shows the compare pattern that survives when both sides are padded first.
- Logs and reports. Number-formatted cells and report toolkits strip the zeros on write, so the archived key stops matching the line.
Fix the length at the reader, not in the string
Set the output once in the reader's symbology configuration and every consumer downstream gets the same payload. The options sit in the 1D symbology group next to the UPC-E and DataBar settings, and three families do the work:
- UPC-A to EAN-13 expansion — transmits all 13 digits, leading zero included.
- GTIN conversion, where the reader offers it — transmits 14 digits whatever the carrier; choose this when the MES already holds 14-digit keys.
- UPC-E expansion — expands compressed UPC-E symbols to their UPC-A or EAN-13 form.
Exact wording differs by vendor, but the job is always the same. Pick one length and keep it everywhere: a 13-digit reader output against a 14-digit database key recreates the problem you just removed. If the payload comes from a software library rather than a reader — the common case in prototype code — pad in your own decode callback: twelve digits in, prepend two zeros before the string reaches any compare.
Readers for mixed UPC/EAN lines
Every fixed reader here decodes UPC and EAN, so the differentiator is optics: pixels across the narrowest bar. A full-size UPC-A is 95 modules wide with 9-module quiet zones each side, so a 40 mm label puts one module near 40 ÷ 113 ≈ 0.35 mm. Aim for 2 pixels across that module; below about 1.5 px per module, decode rates fall away on ordinary print-gain variation. A pixel no larger than 0.35 ÷ 2 ≈ 0.18 mm then sets the geometry: a 1.3 MP sensor, typically 1,280 columns, holds that pixel target over a field of 1,280 × 0.18 ≈ 230 mm. Keep the label field at or under that and every module resolves with margin.
Compact readers cover such fields at short range: both the MV-ID3013PM-12M-WBN and the MV-ID813M-05S-WBN-SR use 1.3 MP sensors, the first with a 12 mm lens, the second with a 4.9 mm focal length, white light and a GigE interface. For one fixed label close to the reader, the LS-CRD-0047 reads a 60–120 mm band over USB 2.0.
- Interface
- Fast Ethernet
- Resolution
- Up to 3 MP
- Interface
- GigE
- Resolution
- Up to 3 MP
- Resolution
- Up to 3 MP
- Shutter
- Global
Case and pallet labels need a wider field at the same pixel density. Step the sensor up to roughly 3,072 columns — a 6 MP part — and the 0.18 mm pixel target covers about 3,072 × 0.18 ≈ 550 mm, which is case-label territory. The MV-IDS006M-12C-C is a 6 MP logistics code reader for that job.
- Interface
- GigE
- Resolution
- 6-10 MP
Shrink film and glossy cartons add specular glare before distance ever becomes the problem. A polarizing cover from the code reader accessories range cuts the specular component first; the accessories finder lists covers and light boards per series, and the code reader finder filters bodies by resolution and interface.
Commissioning checks
- Decode one sample of every carrier on the line — UPC-A carton, EAN-13 carton, any UPC-E — and log payloads with their lengths.
- Pad both payloads to 14 digits and confirm they match digit for digit; that single test separates convention from content.
- Store the key in a text column. An integer column deletes leading zeros at write time and poisons every later string compare.
- Set the same output length on every reader, and enforce it with a length check in the PLC or the logging script.
- For a test pattern independent of line labels, print a known-good symbol with the EAN-13 bitmap generator guide and push it through the same path.
- Printing labels in-house? Mind the quiet zones and the light-margin marker covered in the EAN-13 human-readable text layout guide.
When padding is not the answer
If padded 14-digit keys still disagree, the strings describe different items, not one item in two conventions. Work down this list:
- UPC-E. A compressed symbol governed by GS1 zero-suppression rules, so its expanded form is not simply the printed digits; enable UPC-E expansion and compare after expansion, not before.
- EAN-8. An 8-digit symbol with its own number range for small packages; it is never a truncated EAN-13, though it pads to a 14-digit GTIN like everything else.
- Two genuine GTINs. Similar cartons carrying different items; a padded compare that fails here is doing its job.
- A bad read, not a bad convention. If the padded string fails its check digit, the decode was corrupt — flag it and re-read, never repair digits by hand.
Two readers that pad to the same 14 digits and still disagree on identical cartons point at a data problem, not a decode problem.
The whole fix is one rule: pad left to 14, compare as text. Set it at the reader where you can, in the decode callback where you cannot, and the 12-versus-13 ticket class disappears. To plan a new station end to end, start from the system configurator; the code-reading guides hub collects the rest of this series, and specific MES-matching questions reach the team through the contact page.
Questions
Is every UPC-A also a valid EAN-13?
Yes. Add a leading 0 to the 12-digit UPC-A number and the result is a valid EAN-13 with the same check digit, because the zero contributes nothing to the weighted sum. The printed bars and spaces stay identical, so any reader decodes both forms; which string you get back depends only on how the reader or library reports the symbol.
Why does my code reader drop the leading zero?
It is not dropping anything. The label's bar pattern is physically a UPC-A symbol, and readers report UPC-A as 12 digits; the zero exists only in the EAN-13 convention. Enable UPC-A-to-EAN-13 conversion or GTIN-14 padding in the reader's symbology settings so every payload leaves at a fixed length, or left-pad the payload to 14 digits in your own decode code.
Should I store a GTIN as a number or as text?
As text. Numeric fields and spreadsheet cells strip leading zeros, so 00012345678905 becomes 12345678905 and no longer matches any padded compare. Store the 14-digit padded key in a text or character column, compare barcode results as strings, and check HMI numeric inputs and CSV report paths, which delete zeros just as quietly.
Does converting UPC-A to EAN-13 change the check digit?
No. The check digit comes from a weighted sum, and a leading zero adds 0 whether its weight is 3 or 1. In the worked example, 012345678905 weighs 85 as UPC-A, 95 as EAN-13 with the zero and 85 again as a GTIN-14; the check digit 5 closes all three to a multiple of 10.
What is the difference between UPC-E and UPC-A?
UPC-E is a compressed symbol that fits a UPC-A number into fewer bars for small packages; it is not a UPC-A with a missing digit. Expansion back to UPC-A or EAN-13 follows GS1 zero-suppression rules, so it is a separate reader setting from plain UPC-A expansion. Enable it only when small packages on your line actually carry UPC-E.



