fukuchi / libqrencode

A fast and compact QR Code encoding library
https://fukuchi.org/works/qrencode/
GNU Lesser General Public License v2.1
2.59k stars 599 forks source link

Compatibility issue #115

Open ClaudioRototype opened 7 years ago

ClaudioRototype commented 7 years ago

Dear sirs, we have tried to use this library in our project. At our tests we found the library very good and mobile phone apps read all codes perfectly. Nevertheless the library produces QR codes which are totally not compatible with a Zebra (ex Motorola) reader (precise model: DS457-SR20009 SBRE). None of the generated codes are readable and so far Zebra has not been able to explain. One evidence is anyhow that this library generates QR codes that are visually different from those generated by other libraries (I use for example Zxing as a comparison) even when setting same content, same version and same error correction level. Looking at the standard it seems that the only way to obtain visually different codes with same content, version and error correction level is using a different data masking https://www.thonky.com/qr-code-tutorial/data-masking

But data masking itself is very strictly mandated and it is very unlikely that two different mask score equivalent allowing two different visual alternatives with same merit.

Can you please help me understanding this point and if this library is coherent with the standard while Zxing is not or the other way round or any other reason I might have overlooked. Of course I have no concern with visually different result but since Zebra reader is not reading these codes I'm afraid they might not be optimal or break the standard in some way (I'm not claiming that, Zebra might be broken...).

I noticed that in version 3.3 a fix on the masking has been adopted.

Best regards Claudio

mijoost commented 3 years ago

Hi all,

can confirm that the tool/library looks quite good and useful. I also ran into the problem of different looking QRcode due to different masking settings. It seems that the qrencode tool cannot force a specific mask. This is not a problem of the functionality per se; by hard-patching the desired mask mode (in QRcode_encodeInput()) the resulting QRcode can be made exactly as desired. The real problem is that the parameter cannot be passed from the user to this function, and there is no easy way to extend the library API (QRcode_encodeString()) and all the many chained internal functions in a compatible way.

The suggested fix is a different API architecture, by using a context object, rather than explicit lengthy parameter lists in each encoding function, not limited to the exposed API. The context should should carry all the configuration metadata (version, level, hint/mode, mask, etc.), perhaps similar to QRinput, with appropriate defaults/automatics, and have dedicated overwrite API functions. This would allow to extend the API for future additional parameters without loosing compatibilty for older applications.

best regards, Michael