NetBarcode icon indicating copy to clipboard operation
NetBarcode copied to clipboard

128 barcode are not accurate

Open liviupopovici123 opened this issue 2 years ago • 3 comments

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 image And this is the correct one that should be generated image001 Any thoughts on this?

liviupopovici123 avatar Sep 28 '21 14:09 liviupopovici123

Thanks for reporting, I'm investigating the issue.

Tagliatti avatar Oct 03 '21 19:10 Tagliatti

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 avatar Nov 28 '21 21:11 Vandersteen

@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.

trajekolus avatar Nov 29 '21 00:11 trajekolus