skip2 / go-qrcode

:sparkles: QR Code encoder (Go)
http://go-qrcode.appspot.com
MIT License
2.64k stars 338 forks source link

Missing characters in generated code #25

Open juztin opened 4 years ago

juztin commented 4 years ago

When running:

qrcode "88c77c18" > code.png

The generated code seems to only decode to:

c77c18
skip2 commented 4 years ago

I can't reproduce this:

[tfh@localhost ~]$ go/bin/qrcode "88c77c18" > 88c77c18.png
[tfh@localhost ~]$ zbarimg 88c77c18.png 
QR-Code:88c77c18
scanned 1 barcode symbols from 1 images in 0.02 seconds
[tfh@localhost ~]$ 

Here is the image: https://skip.org/drop/88c77c18.png https://zxing.org/w/decode?u=https%3A%2F%2Fskip.org%2Fdrop%2F88c77c18.png

Can you link to the image you generated? Which software did you use to decode it?

juztin commented 4 years ago

I did notice that I was behind on commits (was on dc11ecd)
Just to make sure I was running against the binary built from this project, from current `master:

  1. Did a git pull
  2. Removed current binary rm $GOPATH/bin/qrcode
  3. Re-built binary go install ./...
  4. Ran the following:
      $GOPATH/bin/qrcode "88c77c18" > 88c77c18.png

The resulting QR-Code decodes to c77c18


If I replace the first the 88 prefix: asdfasdfasdfc77c18, it works
If I prefix it, again, with the eights: 88asdfasdfasdfc77c18, it decodes to: asdfasdfasdfc77c18
If I run directly from the repo: go run qrcode/main.go "88c77c18" > 888c77c18.png it decodes to c77c18

I've tried running in both zsh and bash (just to trying to rule everything out), as well as copying your command above (just replacing the first part with go run qrcode/main.go in the repo directory)

Here's a few other scenarios I've run _(all using go run qrcode/main.go ...:

Update

Just to rule out my machine, I also did the following (same results):

docker run -it --rm --volume "$(pwd)":/output golang
go get -u github.com/skip2/go-qrcode/...
qrcode "3aaaa" > /output/3aaaa.png
skip2 commented 4 years ago

Can your decoder software read "88c77c18" from https://skip.org/drop/88c77c18.png ? Which decoder software are you using? Can you attach your 3aaaa.png?

skip2 commented 4 years ago

QR Codes can contain multiple data types, namely: numeric, alphanumeric, and byte. This minimises the size of each QR code, e.g. as numeric data can be encoded more efficiently than byte data.

If you are having problems decoding numbers, it's possible your decoder software can't decode numeric encoded data correctly.

I have encoded "8888888888aaaa8888" two different ways below. If you can only decode the first type correctly, then your decoder software is broken.

Data segment #0: data type byte: '8888888888aaaa8888' 8888888888aaaa8888_byte_datatype_only

Data segment #0: data type numeric: '8888888888' Data segment #1: data type byte: 'aaaa' Data segment #2: data type numeric: '8888' 8888888888aaaa8888_mixed_datatypes

If neither decodes correctly, then you are probably parsing the output of your decoder incorrectly.

skip2 commented 4 years ago

Is this still an issue?