Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QR Code Not Generated for Strings of 192 to 217 Characters #309

Open
Revanjin opened this issue Oct 26, 2024 · 3 comments
Open

QR Code Not Generated for Strings of 192 to 217 Characters #309

Revanjin opened this issue Oct 26, 2024 · 3 comments

Comments

@Revanjin
Copy link

We've observed that URLs or strings ranging from 192 to 217 characters fail to generate a QR code. The issue stems from a specific line in the code:

javascript
if(buffer.getLengthInBits()+4<=totalDataCount*8){buffer.put(0,4);}

The error encountered is:
Uncaught (in promise) Error: code length overflow. (1756>1056)

Furthermore, we confirmed this behavior on for example the website Vue QR Code Component. Any input within the specified character range fails to produce a QR code.
I also tested this on Codepen. QR Code Codepen

@hq6
Copy link

hq6 commented Oct 28, 2024

@dimitrimabom
Copy link

Issue with QR Code Generation for Strings between 192 and 217 Characters #309

The described issue involves an overflow error that occurs when generating QR Codes for strings ranging from 192 to 217 characters in length. This error arises when the amount of data exceeds the maximum bit capacity of the QR Code version being used. Each version of a QR Code has a predefined storage limit, which depends on both the error correction level (L, M, Q, or H) and the type of data being encoded (numeric, alphanumeric, binary, etc.).

In the provided code snippet:

if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {  
    buffer.put(0, 4);  
}

The problem occurs because the bit length needed to encode the string surpasses the allowed capacity for that specific QR Code. Each additional character consumes a certain number of bits, and for strings within the range of 192 to 217 characters, the data reaches a critical threshold. This range likely marks a point where the data no longer fits within the previous QR Code version's size, but also doesn’t transition smoothly to the next version without exceeding the bit limits.

@Revanjin
Copy link
Author

@dimitrimabom But what does not make sense for me is that everything > 217 is working fine again.. There must be something weird going on... right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants