Skip to content

DetectedBarcode.rawValue could be binary data. #35

Open

Description

@yell0wd0g

DetectedBarcode.rawValue is defined as a DOMString, whereas depending on the barcode itself, it could be binary. Adapt the Spec to reflect that.

Activity

  1. reillyeon commented on Jul 22, 2019

    @reillyeon
    Collaborator

    I've investigated the question of whether or not QR codes can contain binary data and found that it is not the case. The "binary mode" seems to default to the ISO-8859-1 but can be overridden to other character sets using ECI hints.

    Importantly, in our implementation experience within Chromium we found that the barcode detection APIs on Android and macOS return the decoded value as their native string types which are defined as containing UTF-16 codepoints.

  2. reillyeon commented on Jan 31, 2020

    @reillyeon
    Collaborator

    I have repeated this analysis in investigating Chromium issue 1023177 and determine that this data in available from platform barcode scanning APIs.

  3. getify commented on Dec 24, 2025

    @getify

    Any chance this could be revived?

  4. getify commented on Dec 29, 2025

    @getify

    Just for further information, I have built a "proof" that QR codes can indeed support binary data encoded and decoded.

    I forked the qrcodejs library and added a way to force raw bytes into the QR code, then I forked the qr-scanner library so that if I scan a QR code encoded with binary data, it comes out raw WITHOUT any text transformation (which is inherently susceptible to different choices of character encodings).

    I've tested this on several platforms and with a variety of different binary data, and it seems to be working seamlessly.


    The unfortunate part of my qr-scanner fork is that I had to forcibly disable it from using the native BarcodeDetector web API, so that it falls back to its included port of Google's ZXing library.

    From a performance perspective, it'd be highly preferable if this API could be updated to support the raw binary data on the result. Ideally, this API (with binary data support) would eventually be widespread enough the scanner library could drop its inclusion of the ZXing library port altogether.

  5. jimmywarting commented on Jan 1, 2026

    @jimmywarting

    think we should have something like what already exist in push event, blob & fetch

    namely:

    barcode.text()
    barcode.bytes()
    barcode.arrayBuffer()
    barcode.json()
    barcode.blob()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions