When Generating "QRCode" the following above error was generated
The the string whose Qrcode is resulting in error
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)
+1 got the same error
+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...
@plapinhh Try a really long string and check does it break
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:
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.
irb(main):003:0> text = "a"*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.
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.
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
qr = RQRCode::QRCode.new(qr_data, :size => qr_size, :level => :l)
rescue RQRCode::QRCodeRunTimeError => e
qr_size += 1
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.
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.
Very cool, thanks 👍 using the fixed version then 😄
I've had mostly great results with rqrcode-with-patches, with one exception.
You can view details here bjornblomqvist@whomwah:master...master
From my experience (and I encourage you to test this for yourself), RQRCode::QRCode.new(qr_text) fails, throwing 'code length overflow' when 194 < qr_text.length < 221
It's a bizarre bug -- normally it auto-selects the proper size very well. Can anyone else confirm / comment on this?
Switches to rqrcode-with-patches
from whomwah/rqrcode#15 (comment)
it seems that rqrcode has been abandoned so i'm using the recommended one:
I have added a hint in the error on how to fix it.
RQRCode::QRCodeRunTimeError: code length overflow. (540>288) (Try a larger size!)