NetBarcode
NetBarcode copied to clipboard
128 barcode are not accurate
Hi,
I've tried to encode "10500400412728169" using 128 and 128C. They are the same. I've tried to decode using an online tool and it decodes as "010500400412728169".
This is the generated barcode
And this is the correct one that should be generated
Any thoughts on this?
Thanks for reporting, I'm investigating the issue.
It appears to be happening when having an 'uneven' number of numbers:
Generates a correct barcode:
- 1234
- 123456
- 12345678
Generates a barcode prefixed with 0:
- 123
- 12345
- 1234567
Which appears to be coming from: https://github.com/Tagliatti/NetBarcode/blob/ad1402ab4bf5cf18e251be58ae9ea55d1e1455ab/NetBarcode/Types/Code128.cs#L255
I don't have knowledge of the CODE128 barcode structure so this might be correct behaviour
@Vandersteen I think it is correct behavior because Code128 automatically switch between the three subsets (A, B, and C) to code the data in the shortest form. And if subset C is picked, a leading "0" is added if there are an odd number of digits in the code as you also found.
Specifying Code128B specifically solved the issue for me.