NaturalHistoryMuseum / pyzbar

Read one-dimensional barcodes and QR codes from Python 2 and 3.
MIT License
728 stars 176 forks source link

Support decoding of binary QR codes #82

Open KlaasJelmer opened 4 years ago

KlaasJelmer commented 4 years ago

When the ZBar decoder encounters binary data, it guesses the data encoding while converting it to text. This behavior destroys other types of data.

Version 0.23.1 of the ZBar library supports decoding binary QR codes using configuration option ZBAR_CFG_BINARY. This PR allows settings this flag from the decode() function

coveralls commented 4 years ago

Coverage Status

Coverage decreased (-0.2%) to 97.877% when pulling 2b12b686079bee0500e438783d103a17b2a5bdf3 on KlaasJelmer:master into 833b375c0e84077943b7100cc9dc22a7bd48754b on NaturalHistoryMuseum:master.

maglub commented 6 months ago

Is there a good way to get attention to this pull request?

This would be quite a nice and useful workaround for issues in Europe, where the base library zbar mis-interprets the encoding:

My workaround for now is the following, which could be avoided if one could just get the binary representation of the QR codes:

  try:
    logging.info("  - Trying the ugly workaround to re-encode utf-8 to big5, then back to utf-8")
    logging.info(res[0].data.decode('utf-8').encode('big5'))
    return res[0].data.decode('utf-8').encode('big5').decode('utf-8')
  except:
    logging.info("  - Re-encoding failed, so the qrcode is probably ok already in utf-8")
    logging.info(res[0].data.decode('utf-8'))
    return res[0].data.decode('utf-8')
pauuser commented 5 months ago

Getting the same issue. Hope this pull request gets more attention as soon as possible!