libqrencode icon indicating copy to clipboard operation
libqrencode copied to clipboard

Optimal text segmentation

Open RCasatta opened this issue 2 years ago • 1 comments

According to https://www.nayuki.io/page/optimal-text-segmentation-for-qr-codes the optimal text segmentation of the string bitcoin:BC1PF4CHVJTQGVWNQ2VURZUJX623JVWUDEYC2MNQUFLXZD0K4FQ870QS40G5XT?amount=0.00000111&label=Prova%20QR&message=Hello results in 821 encoded bits, while it seems a QR encoded from qrencode achieve 832 bits with the following segments:

[Segment { mode: Byte, begin: 0, end: 7 }, Segment { mode: Alphanumeric, begin: 7, end: 70 }, Segment { mode: Byte, begin: 70, end: 119 }]

The optimal segmentation includes a Numeric segment that is not included by qrencode

image

RCasatta avatar May 10 '23 17:05 RCasatta

Note that the optimal text segmentation depends on the version number used. My segmentation is optimal for versions 1 to 26 (though the text requires at least version 5 at low ECC). Fukuchi's segmentation is optimal for version 27 to 40. You can see this when you play with my web page and override the minimum version to at least 27.

Though, after glancing at split.c and qrinput.c, I don't see any obvious explanation for the code's behavior.

nayuki avatar May 11 '23 01:05 nayuki