String content = new String(data.readAllBytes(), StandardCharsets.UTF_8);
This ends up with additional bytes, which will cause an exception in the BarcodeGenerator like
“Maximum characters limit reached for BINARY compaction mode and 2 error correction level. Encoded data length - 1345. Max available length - 1102.” - Where the initial byte array length is 782 - largely below the limit…
Doing something like: byte[] dataBA = data.readAllBytes(); char[] charEncoded = new char[dataBA.length]; for (int i = 0; i < dataBA.length; ++i) { charEncoded[i] = (char)dataBA[i]; } String content = new String(charEncoded);
doesn’t help either. The “problem” seems to be in the constructor of String.
From debugging see the difference when stopping at line 23:
see picture in upper mail post
The content string is blown up. Seems to be utf-16.
By consequence the content will be too big for data in normal use.
(of course: the hello world functions, as always…)
We have logged a ticket with an id “BARCODEJAVA-1334” for your issue/requirements. We will investigate and look into the details and try to sort it out.
Once we have an update on it, we will let you know here.
Additional information about the byte array:
The byte array contains 10 leading bytes with an identification number and a zip. Byte 10 and 11 have the value 80 and 75, makes PK which is the start marker for the zip.
The content of the zip is:
Hello world!
Thanks for sharing the workaround and good to know that your issue is sorted out by changing the charset. Should we close the thread/ticket or you need us to continue to evaluate the issue?