You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Yes - As far as I can tell, when scanning a binary-encoded QR code, it's converted into a string, and the bytes do not match up when I attempt to decode it.
Describe the solution you'd like
In an ideal world, it'd be great if Koder could automatically detect when a qr code is binary-encoded, and automatically return a byte array / UInt8Array. But another nice option would be if Koder simply always outputted a byte array, because you can always use a TextDecoder to convert it to a string later in the pipeline.
Describe alternatives you've considered
I tried using TextEncoder to encode the returned string back into a Uint8Array, but the bytes were completely different. Putting an example at the bottom of the issue.
I've tried delving into the code and modifying getScanResults() to return an array of uint8_t* instead of str* without using strcpy, and then modifying koder.js to copy the pointer as a JS Array / UInt8Array, but I got stuck on the last part. I couldn't find any methods related to copying an array pointer back to JS in Emscripten's preamble, but I found this stackoverflow post and it went WAY over my head. I've never done anything with WebAssembly and my experience with C++ is extremely limited, so this is a little above my pay grade, so to speak.
Additional context
I'm writing a mobile web app that's designed to use QR codes to transmit data between devices. Since the QR codes are being both created and scanned in-app, we have the benefit of the scanner "expecting" the qr code to be encoded in a specific format.
I'm using the NodeJS package qrcode to encode my qr codes. When compressing my data, I'm using LZMA, which already outputs an array of bytes. When I have to encode that array of bytes to Base64, it costs an additional 33% of data size, so it'd be ideal if I could just encode it in binary and then decode it as binary. According to the readme of qrcode (https://www.npmjs.com/package/qrcode#binary-data), converting binary data to a JS string adds extra bytes, which I assume is the reason why the bits in the outputted string look completely different from the original data.
Example of using TextEncoder to try and recover the original bytes:
Original Uint8Array:
I can't find any patterns in this result that indicate any resemblance to the original data. Additionally, the array is shorter and I don't know why that would be.
The text was updated successfully, but these errors were encountered:
@maslick Thanks for such a quick response! Sure. Here's the QR code with the binary data I included as the example:
Side note: I looked around for a native app that can scan binary data, and it looks like the app Binary Eye scans the binary data correctly (after you convert the data to hex):
I should note one thing: During my research the other day, I found this stackoverflow post: https://stackoverflow.com/questions/37996101/storing-binary-data-in-qr-codes
and in the person's notes, they said ZBar can't handle null bytes. If this is the case, then maybe in the generation side, I could manually replace null bytes with something else, like idk, five 01's in a row or something.
Is your feature request related to a problem? Please describe.
Yes - As far as I can tell, when scanning a binary-encoded QR code, it's converted into a string, and the bytes do not match up when I attempt to decode it.
Describe the solution you'd like
In an ideal world, it'd be great if Koder could automatically detect when a qr code is binary-encoded, and automatically return a byte array / UInt8Array. But another nice option would be if Koder simply always outputted a byte array, because you can always use a TextDecoder to convert it to a string later in the pipeline.
Describe alternatives you've considered
getScanResults()
to return an array ofuint8_t*
instead ofstr*
without usingstrcpy
, and then modifyingkoder.js
to copy the pointer as a JS Array / UInt8Array, but I got stuck on the last part. I couldn't find any methods related to copying an array pointer back to JS in Emscripten's preamble, but I found this stackoverflow post and it went WAY over my head. I've never done anything with WebAssembly and my experience with C++ is extremely limited, so this is a little above my pay grade, so to speak.Additional context
I'm writing a mobile web app that's designed to use QR codes to transmit data between devices. Since the QR codes are being both created and scanned in-app, we have the benefit of the scanner "expecting" the qr code to be encoded in a specific format.
I'm using the NodeJS package
qrcode
to encode my qr codes. When compressing my data, I'm using LZMA, which already outputs an array of bytes. When I have to encode that array of bytes to Base64, it costs an additional 33% of data size, so it'd be ideal if I could just encode it in binary and then decode it as binary. According to the readme ofqrcode
(https://www.npmjs.com/package/qrcode#binary-data), converting binary data to a JS string adds extra bytes, which I assume is the reason why the bits in the outputted string look completely different from the original data.Example of using TextEncoder to try and recover the original bytes:
Original Uint8Array:
Resulting string:
Result of
new TextEncoder().encode(str)
:I can't find any patterns in this result that indicate any resemblance to the original data. Additionally, the array is shorter and I don't know why that would be.
The text was updated successfully, but these errors were encountered: