Closed
Description
Thank you for the great library!
We are encountering a very seldom but huge Issue where some binary data is wrongly encoded in the barcode.
Usually we are taking binary data as base64 and render it into an azteccode. Very seldomly those barcodes return the wrong data back after scanning. (Tested by multiple different barcode-scanners used in public transit. For my testing I use the QRbot App but the result is the same on every scanner.)
Putting the same data into Apple-Wallet PKPass works.
I was able to find two examples. In HEX the following happens (Only the part and a few bytes around the part that breaks)
IN: "6A 3E E8 AD F2 EF 17 99 3A 20 53 94 9F C3 1D 87"
OUT:"6A 3E E8 AD F2 EF 17 99 2F 94 9F C3 1D 89 46"
IN: "1D CE A4 2E 20 44 04 BD 19 7D A4 C9 18 1D 3E 74"
OUT:"1D CE A4 3A 20 04 BD 19 7D A4 C9 18 1D 3E 77"
I built you an example that directly takes the binary from hex. Tested on latest commit (ec9c2c8).
<!doctype html>
<html><head><title>bwip-js - JavaScript Barcode Generator</title>
<meta charset="utf-8" />
<script type="text/javascript" src="../dist/bwip-js.js"></script>
<canvas id="canvas" width=400 height=400 style="border:1px solid #fff"></canvas>
<script type="text/javascript">
hex_data = "6A 3E E8 AD F2 EF 17 99 3A 20 53 94 9F C3 1D 87"
// Working example -like most data-:
// IN: "BC 64 0E 20 47 C8 6B 52 2D 81 76 A8 FA E4 7B B9"
// OUT:"BC 64 0E 20 47 C8 6B 52 2D 81 76 A8 FA E4 7B B9"
// Broken examples
// IN: "6A 3E E8 AD F2 EF 17 99 3A 20 53 94 9F C3 1D 87"
// OUT:"6A 3E E8 AD F2 EF 17 99 2F 94 9F C3 1D 89 46"
//
// IN: "1D CE A4 2E 20 44 04 BD 19 7D A4 C9 18 1D 3E 74"
// OUT:"1D CE A4 3A 20 04 BD 19 7D A4 C9 18 1D 3E 77"
function hexToByteString(hex) {
let bytes = "";
for (let c = 0; c < hex.length; c += 3)
bytes += String.fromCharCode(parseInt(hex.substr(c, 2), 16));
return bytes;
}
binary = hexToByteString(hex_data)
canvas = bwipjs.toCanvas('canvas',{
bcid: "azteccode",
text: binary,
binarytext: true,
scale: 2,
eclevel: 23,
})
</script>
</div>
</body>
</html>
Metadata
Metadata
Assignees
Labels
No labels