How can I validate diverse barcode encodings using PHP?

953 views Asked by At

I'm tasked with validating GTIN-14, GTIN-13, GTIN-12, GTIN-8 and UPC-E barcodes. I have seen a few functions here and there, however I'm unclear on how to validate the code without knowing ahead of time which standard is in use.

I assume this must be possible, but I'm at a loss as to where I should begin.

1

There are 1 answers

0
tobltobs On

Validating the content of the barcode shouldn't be a problem. Take a look at the specification for the different GTIN-Formats. The problematic part is to check the existence of the required GS1 Symbol identifier. The commonly used libs for barcode decoding (zxing, zbar) do not give you the Symbol identifier. The only exception is zxing for Code-128. If you have to check other carrier types you will have to look into commercial decoders. Take a look at this question for more details.