QR Code encoding and decoding using zxing
So, for future reference for anybody who doesn't want to spend two days searching the internet to figure this out, when you encode byte arrays into QR Codes, you have to use the ISO-8859-1
character set, not UTF-8
.
Decoding QR Code embedded into PDF with ZXing on Java backend
Your code works if one removes
hints.put(DecodeHintType.PURE_BARCODE, Boolean.FALSE);
I suspect that ZXIng only checks whether there is an entry for the key and not its value. The javadoc mentions "Doesn't matter what it maps to; use Boolean.TRUE."
Encoding and decoding byte[] with ZXing
You are making the mistake of thinking that you can turn arbitrary binary data into a valid string without using some kind of armouring. It doesn't work. Binary -> text -> binary is lossy using any of the standard character sets / encoding. (Hint: using UTF-8 won't work either.)
You should use something like base64 encoding or hexadecimal encoding to ensure that the binary data doesn't get mangled.
Show errors during decoding QRcode. Using ZXing Java library
It's a good idea to try reading the source first. In com.google.zxing.common.reedsolomon.ReedSolomonDecoder
, there is a method findErrorLocations()
which pretty clear does exactly this.
Encoding and decoding random byte array with zxing
Try PURE_BARCODE
mode as a detection hint. Strangely, false positive detection of finder patterns is a much bigger problem when the image is just a pure synthetic image. The heuristics assume a photo, which doesn't have these problems. In this alternate mode it can take advantage of knowing it's a pure image and not a photo and be much faster and never get the detection wrong.
Storing binary data in QR codes
It turned out that ZXing is just crap, and ZBar does some weird stuff with the data (converting it to UTF-8 for example). I managed to get it to output the raw data including null bytes though. Here is a patch for the best Android ZBar library I found, that has now been merged.
Related Topics
Why Shouldn't Java Enum Literals Be Able to Have Generic Type Parameters
How to Simulate a Real Mouse Click Using Java
Does Java Have Any Mechanism for a Vm to Trace Method Calls on Itself, Without Using Javaagent, etc
Making a Log4J Console Appender Use Different Colors for Different Threads
How to Compile Java to Native Code
Differencebetween Canonical Name, Simple Name and Class Name in Java Class
Java: Subtract '0' from Char to Get an Int... Why Does This Work
When and How Are Classes Garbage Collected in Java
Why Should One Use Objects.Requirenonnull()
Why Were Most Java.Util.Date Methods Deprecated
Java Io Ugly Try-Finally Block
How to Solve the "A Generic Array of T Is Created for a Varargs Parameter" Compiler Warning
Error: Java_Home Is Not Defined Correctly Executing Maven
How to Get *Everything* Back from a Stored Procedure Using Jdbc
How to Get Method Parameter Names in Java 8 Using Reflection
How to Get Java to Ignore the "Trust Store" and Just Accept Whatever Ssl Certificate It Gets