uic-918-3
uic-918-3 copied to clipboard
Zxing wrong encoding
I noticed that in my 28 test tickets, I have 6 tickets which do not work with this library.
I have one ticket where it works if I present the Aztec code from the App main screen, but it does not work if I present the Aztec code from the App "PDF" view (for the same ticket!). So there seems to be a problem with the Aztec code itself and not the ticket.
This python library can decode both of them, but the following fix was required. I think you should this in NodeJS too:
def fix_zxing(data):
"""
ZXing parser seems to return utf-8 encoded binary data.
See also http://code.google.com/p/zxing/issues/detail?id=1260#c4
"""
data = data.decode('utf-8').encode('latin1')
# zxing parsing also adds a newline to the end of the file. remove that.
if data.endswith(b'\n'):
data = data[:-1]
return data
EDIT: This fix should only be applied if there was a failure, and this would be the 2nd try then.