barby icon indicating copy to clipboard operation
barby copied to clipboard

EAN13.rb said to handle UPC-A but it requires 12 digits passed

Open RichardGrossman opened this issue 9 years ago • 1 comments

I padded the number to be represented with the arcode to 12 diits with 0's on left, and it was readable by a UPC-A reader and identified as UPC-A but that was one test. Did I handle this in the correct way?

 def barcode_output(barstring)
    barcode_string = barstring.to_s.rjust(12,"0")
    barcode        = Barby::EAN13.new(barcode_string)
  
    # PNG OUTPUT
    data           = barcode.to_image(height: 40, margin: 10).to_data_url

RichardGrossman avatar Apr 04 '17 04:04 RichardGrossman

Digit 13 is a check digit, not part of the data.

toretore avatar Apr 04 '17 13:04 toretore