ankane / barkick

Barcodes made easy
MIT License
136 stars 12 forks source link

UPC-E detection skips valid UPC-E codes #3

Closed scashin133 closed 6 years ago

scashin133 commented 6 years ago

00985234 is a valid UPC-E barcode but the current GTIN library skips it because the 2nd digit is a 0.

image of 00985234 upce code

Do you know why for the detection you ignored codes where the 2nd digit is a 0? I searched but couldn't find anything saying this was a valid way to differentiate the codes.

I'm happy to work on a fix, but would want to learn more about why the detection works the way it does today.

ankane commented 6 years ago

From the tests, looks like it was for Trader Joe's, which uses EAN-8. I think the issue is there may not be a reliable way to tell if an 8-digit code is UPC-E or EAN-8. We probably need to pass this info from the scanner to Barkick for 8-digit codes.

ankane commented 6 years ago

You can now do GTIN.new(code, type: :upc_e) on master.

ankane commented 6 years ago

Pushed a new version as well - upgrade instructions here https://github.com/ankane/barkick#010