Skip to content
This repository

RQRCode::QRCodeRunTimeError: code length overflow. (372>288) #15

Open
meetme2meat opened this Issue · 9 comments

6 participants

Viren Negi Matthias Hecker plapinhh j03w jamesprior Mike Wille
Viren Negi

When Generating "QRCode" the following above error was generated

The the string whose Qrcode is resulting in error

"http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_div_align"

The Code

 RQRCode::QRCode.new("http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_div_align", :size => 4, :level => :h )
RQRCode::QRCodeRunTimeError: code length overflow. (540>288)

Matthias Hecker
4poc commented

+1 got the same error

plapinhh

+1 the same.

i've fixed it by increasing the :size option's value ( RQRCode::QRCode.new( url.to_s, :size => 10, :level => :l) ) and controlling my urls length...

but, i have not yet looked what the mean is...

Viren Negi

@plapinhh Try a really long string and check does it break

j03w

QR code version 4 with high level error correction give you maximum length of 50 alphanumeric characters

Follow the link to see full matrix of maximum capacity for each version:

http://www.qrcode.com/en/vertable1.html

jamesprior

Note that the chart gives some guidelines but it looks like the rqrcode library is not using any of the numeric or alphanumeric modes, only data.

Eg:

irb(main):003:0> text = "a"*50
=> "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
irb(main):004:0> text.length
=> 50
irb(main):005:0> qr = RQRCode::QRCode.new(text, :size => 3, :level => :m)
RQRCode::QRCodeRunTimeError: code length overflow. (412>352)

It looks like I'm passing 50 characters, and at size 3 level m the chart says the limit is 61. Instead it errors and tells me that there are more data bits than allowed.

Mike Wille

I'm hitting this same problem as well. My testing shows it only uses the binary mode. I thought passing message using str.encode("us-ascii") might trigger alphanumeric, but it doesn't.

jamesprior

FWIW, I ended up just putting my QR code generation inside a loop to find the best fit size. It is Not Great but functional. I post it as a way to illustrate what I'm talking about but please take a critical look before using it anywhere else.

  qr_size = 3
  qr = nil
  while qr == nil && qr_size < 10
    begin
      qr = RQRCode::QRCode.new(qr_data, :size => qr_size, :level => :l)
    rescue RQRCode::QRCodeRunTimeError => e
      qr_size += 1
    end
  end
Mike Wille

That's a good tip. Thanks!

Digging through the code, I've found there is no support for any mode except binary. I'm quite surprised by that. Check out QR8bitByte and QRCode classes. I was hoping to create a new QRAlphaByte class, but I'm not familiar enough with the code to create something that works.

Mike Wille

Okay, this is the guy to use: https://github.com/bjornblomqvist/rqrcode

Lot's of progress on the code here, including the ability to encode alphanumeric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.