Thoughtworks.qrcode Causes and workarounds for "index exceeded array bounds" prompt when generating QR code

Source: Internet
Author: User
Tags control characters

"Index is out of array bounds" It is also possible that the QR code version you choose does not have enough capacity to store what you put in, and if you are sure that the version capacity QR code can store your content, but still error, then consider this workaround

These two days busy to do a customer label printing program, because there are control characters in the QR code, there are some problems using the ZPL directive, so decided to use the generation of two-dimensional code image and then converted to ZPL format picture to print. On the way to find a lot of class library, many can not customize the QR version and give up, to find ThoughtWorks.QRCode.dll, the effect is very satisfactory, but when the test found that often prompted "index beyond the array bounds" exception, began to think that there is too much content reasons. Testing multiple versions is not working, I am using version=10, and this version can hold up to 213 bytes, the actual content is only more than 100 bytes. Then find the answers on the web, or set to 0 (0 is the QR automatic size) So I use the class library is meaningless, and use this method has been tested, still error.

Then I began to find Thoughtworks.qrcode source, using the source line debugging, the results found using the source of the demo program, set the same version as my program, put the same content, unexpectedly no error, at this time I am sure it is not because of the two-dimensional code capacity caused.

Then I started two program synchronization debugging, one line to observe the source code QRCodeEncoder.cs each of the two programs run the same value (the calculation is too complex, the full commissioning of more than half an hour), and finally in my program in the source code on the No. 448 line found the exception, the source demo but not. Look at the code, read a file here,

Then found in the source demo program generated folder has such a folder (), according to 448 lines of understanding, this folder should be stored in the QR corresponding to the version of the data file for the calculation of two-dimensional code capacity, and my program does not have this folder calculation result is 0, the subsequent calculation will be reported naturally " The index exceeded the array bounds exception.

Copy this folder into the program, the problem is resolved, this exception is no longer reported.

Data File upload next time

Thoughtworks.qrcode Causes and workarounds for "index exceeded array bounds" prompt when generating QR code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.