Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12 digit UPC-A barcodes are detected as EAN-13 with an extra '0' in front on iOS #88

Open
tochichiang opened this issue Aug 21, 2024 · 8 comments

Comments

@tochichiang
Copy link

tochichiang commented Aug 21, 2024

12 digit UPC-A barcodes are always detected as 13 digit EAN barcodes with extra '0' in front. This only happens on a tested iPhone SE 2nd gen, both front and rear cameras. It works fine on tested Android phones.

.Net 8.0 MAUI project
BarcodeScanning.Native.Maui NuGet package 1.5.7
iPhone SE 2nd gen on iOS 17.5.1. (Updated to 17.6.1 and the issue remains)

@tochichiang tochichiang changed the title 12 digit UPC-A barcodes are detected as EAN-13 with an extra '0' in front 12 digit UPC-A barcodes are detected as EAN-13 with an extra '0' in front on iOS Aug 22, 2024
@afriscic
Copy link
Owner

Hello. Sorry for slow response.
iOS doesn't have support for for UPC-A directly, rather it interprets it as EAN-13 with a leading 0. As per ChatGPT:

UPC-A can be represented as EAN-13: When international products are scanned, UPC-A codes can be converted to EAN-13 by simply adding a leading zero. This ensures compatibility with systems that expect the 13-digit format.

@tochichiang
Copy link
Author

Hello. Sorry for slow response. iOS doesn't have support for for UPC-A directly, rather it interprets it as EAN-13 with a leading 0. As per ChatGPT:

UPC-A can be represented as EAN-13: When international products are scanned, UPC-A codes can be converted to EAN-13 by simply adding a leading zero. This ensures compatibility with systems that expect the 13-digit format.

My app needs exact match instead of EAN-13 equivalent. I found that some apps in Apple's app store have the same behavior but some don't. Hope this library can return exactly what it is instead of EAN-13 equivalent.

@thomasgalliker
Copy link

The thing is, there is no fool-prove way to distinguish between UPC-A and EAN-13. Native iOS symbologies do not even offer to scan for UPC-A that's why this library maps UPC-A to EAN-13.

How would you distinguish if "0012345678901" is UPC-A or EAN-13? The leading "0" can also be used for EAN-13 barcodes as far as I know.

@afriscic
Copy link
Owner

afriscic commented Oct 1, 2024

Depending on your use case. If it is retail than you are always working with EAN-13 encoded GTINs and than the first 3 digits are always encoding the country code or UPC-A compatibility:
https://en.wikipedia.org/wiki/List_of_GS1_country_codes

Otherwise, you could technically encode any random 13 digit combination into an "EAN-13 like" barcode outside of the GS1 standard. But AFAIK this is highly discouraged to prevent confusion.

@tochichiang
Copy link
Author

Depending on your use case. If it is retail than you are always working with EAN-13 encoded GTINs and than the first 3 digits are always encoding the country code or UPC-A compatibility: https://en.wikipedia.org/wiki/List_of_GS1_country_codes

Otherwise, you could technically encode any random 13 digit combination into an "EAN-13 like" barcode outside of the GS1 standard. But AFAIK this is highly discouraged to prevent confusion.

My app searches certain websites by the scanned barcode. Some websites do exact match only. If EAN13 doesn't match anything, it returns nothing instead of trying to remove leading 0 and search again. Sure my app can do UPC-A search again but the response time becomes slower because of the first try. In my opinion the implementation of iOS symbology is bad.

@mferrari-magaya
Copy link

We have the same issue in our app, We need to match exact barcodes instead of encoding everything into EAN-13.

@thomasgalliker
Copy link

So, since we all know that the limitation is the Vision Framework provided by iOS, what do you suppose would @afriscic do to solve this issue? I think we cannot just interpret barcodes with leading '0' as UPC-A because it could technically also be an EAN13. The only situation where we could do this is, if your scanner has only activated barcodeformat=upc-a (and not ean13). Any other way to distinctly differ between EAN13 and UPC-A is highly welcome.

@ukehartmann
Copy link

We're expecting this behaviour. So if this is changed, it should also mark the code type to UPC. I agree with @thomasgalliker that this is not an issue for this library but Apple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants