While decoding a barcode of type UPCA, the library adds a extra 0 to the decoded results. So the decoded result has 13 digits instead of 12
Please find the decoded results
{
format:7
numBits:0
rawBytes:null
resultMetadata:null
resultPoints: [ResultPoint, ResultPoint]
text:"0885909934096"
timestamp:1536309792565
...
}

Stale issue message
This issue was not resolved yet.
This is still an issue?! I will investigate if i can but i have not played around with development on this library at all. i am looking for a solid barcode reader in js and this is the only working example i can find.
I believe it is. I did not work on this since I had other priorities, also I never really used UPC-A, this is entirely community sourced. Lately we begin to experience some of these strange errors as the library grows, so I had no time to go back and fix everything. Give it a try, let me know what you found. _Fun fact: I was just looking at this issue today as I had saved it to take a look later, months ago, hehe._
I will give it a look over tomorrow thanks!
The reason it is returning 13 char is due to EAN13Reader being the decoder that decodes it.
I am looking into it
/src/oned/MultiFormatUPCEANReader.ts has a comment: // todo add UPC_A, UPC_E
I have to figure out how to add one in.
Im going to attempt to copy the EAN13Reader to a UPC_A file and wire it up.
You can take a look at the Java version source code to help you.
Here we have the multi-format ONE-D, which is already used by our multi-format reader: https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/MultiFormatOneDReader.java#L37
It uses the multi-format UPC EAN reader:

This reader then checks if UPCA format is given in the hints map and then adds the reader:

So, for our code, the only thing left is check if the UPCA format hint is there and then add, this can be done in this piece of code:
With something like this:

The only problem is that we don't have none of those readers (UPCA, UPCE) ported yet.
Some would have to port one of them so it can work properly.
I hope it helps. 🙂
I see, you are a godsend! Thank you for the java code to use as reference! I believe I can make some progress with this, ill see what i can come up with.
OMG! its just EAN13Reader();
all i have to do is strip off the 0 at the beginning, I think i got this :P
https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/UPCAReader.java#L36
if (text.charAt(0) == '0') {
Result upcaResult = new Result(text.substring(1), null, result.getResultPoints(), BarcodeFormat.UPC_A);
if (result.getResultMetadata() != null) {
Edit: added file name
~Holly forking shit.~ Now who is the god sent. 😄
That's probably due to some EAN13 rule, as we can see the lib does put a zero in the start of the string in here for example: https://github.com/zxing/zxing/blob/3c96923276dd5785d58eb970b6ba3f80d36a9505/core/src/main/java/com/google/zxing/oned/EAN13Reader.java#L103
UPC can't be too hard to port, since almost everything is already in here. Anyone interested: be my guest! PRs are very welcome.
https://github.com/sam2332/library/tree/GHI-88_Barcodes-of-Type-UPC-A-gets-decoded-incorrectly
I am working on a pr over here
Feel free to open a draft PR If you need any help.
I will submit a draft PR tomorrow I'm sorry I spelled on this but I got
most of the code implemented I'm just not sure where I'm going wrong on it
On Sun, May 17, 2020, 11:11 PM Luiz Machado notifications@github.com
wrote:
Feel free to open a draft PR If you need any help.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/zxing-js/library/issues/88#issuecomment-629921720,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAHG3VVGU4Q5TEGP3VKBCATRSCRMLANCNFSM4FTZXNQQ
.
No worries, open it and I'll take a look ASAP. I just can't promise we will be done this week, as I have lots of important work stuff to work on, but we'll get it working soon.
https://github.com/zxing-js/library/pull/304 I have created the draft pr
its not in working order but this is my first time using typescript.
Most helpful comment
https://github.com/sam2332/library/tree/GHI-88_Barcodes-of-Type-UPC-A-gets-decoded-incorrectly
I am working on a pr over here