We fixed a bug today in Okapi that I think may affect Zint as well, since the Okapi Data Matrix encodation logic is almost identical to the Zint logic.
To summarize, the encodation modes C40, TEXT, X12 and EDIFACT all accumulate values in a value buffer of size 8. In some scenarios, 4 elements may be added to this buffer at a time (upper shift + shift set + value), but only 3 elements are flushed from it before moving on to the next character to be encoded. This means that for each input character processed, we may be leaving one value in the buffer. This is usually fine, but if it happens too many times in close sequence, these extra values can accumulate and eventually 9 buffer slots are required (which we don't have).
The fix implemented in Okapi was to flush as many groups of 3 values as possible from the buffer before moving on to the next character, rather than only flushing one group of 3 per input character.
See this Okapi commit for fix details and a test case:
https://github.com/woo-j/OkapiBarcode/commit/0f73a04588c66419558397d031a2bf100ce45e1e
Hi Daniel,
An interesting bug and a very neat solution. Thank you for taking the time to let me know about this. I have patched dmatrix.c accordingly.
Robin.