简体   繁体   中英

How can I validate diverse barcode encodings using PHP?

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.

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.

Check out https://github.com/ronanguilloux/IsoCodes

It provides validators for GTIN-14, GTIN-13, GTIN-12, GTIN-8 and more

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM