-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
DataTooLongException: Generating QR Code for URL Payload with fixed version #583
Comments
Alphanumeric only contains uppercase characters. Convert your url completely to uppercase and it will select the alphanumeric encoding mode automatically. |
I understand. What should I do in the case that a query parameter in my URL is case sensitive and requires I send lowercase characters as well to get the results? I tried converting the URL completely to uppercase but visiting the webpage no longer worked. |
Any lowercase characters will require the byte character mode. I think QR codes can switch modes mid-stream but I don’t think the QRCoder library contains logic to do so. (?) The easy answer of course is to use a larger QR code or generate shortened urls somehow (e.g. private or third party server). Note that most servers have case-sensitive paths, so switching to uppercase would only work if it is known that the server is case insensitive. Often this is the case with Windows-based servers. |
Depending on your requirements maybe some parameters can be eliminated. The following is an Amazon example of two urls which point to the same location: |
Thank you for the suggestions. I ran some tests, including converting the mandatory lowercase letters to its hexadecimal value, and the link still worked, leaving only uppercase letters. However, it continues to choose the byte encoding mode because of the following characters: ?, &, and =. I just wanted to know if shortening the URL or choosing a larger QR version are still the only options for me at the moment. Are those characters not considered alphanumeric? I appreciate your assistance. |
please see QR Code - Information capacity which describes the exact characters available for each encoding mode |
But QRCoder doesn't contain code to mix encoding modes in an attempt to shorten the encoded code; it just picks the mode that all characters will fit into and uses it. |
I ** think ** you can encode the payload yourself and use QRCoder to apply checksums and encode it into a graphic. But I'm not sure; it might be a private method. Probably rather complicated anyway. |
Type of issue
[x ] Bug
[ ] Question (e.g. about handling/usage)
[ ] Request for new feature/improvement
Expected Behavior
I'm trying to generate a version 8 QR Code to share an URL, and I thought it would simply generate it with the specified parameters
Current Behavior
However, it throws the following exception:
QRCoder.Exceptions.DataTooLongException: 'The given payload exceeds the maximum size of the QR code standard. The maximum size allowed for the chosen parameters (ECC level=M, EncodingMode=Byte, FixedVersion=8) is 152 bytes.'
Possible Solution (optional)
I noticed that the encoding mode selected for the text is Byte even though the text is Alphanumeric. I took a look at the code and found out that this is the method used to assign the EncodingMode, and the highlighted . According to qrcode.com, the maximum byte size for a version 8 QR Code with an alphanumeric encoding and an ECC-level M is 221, which would fit my URL, an alphanumeric text.
Steps to Reproduce (for bugs)
Your Environment
The text was updated successfully, but these errors were encountered: