Problems in generating a proper qr-code using zxing
i have a problem in generating proper qr-codes with the zxing api. I am able to generate a qr-code but when i read the qr-code then chars like "äü" arent displayed right.
code:
BitMatrix matrix =开发者_如何学Go writer.encode(text, BarcodeFormat.QR_CODE, 200,200);
//text is String text = "geändert";
bufferedImage = MatrixToImageWriter.toBufferedImage(matrix);
If i start with "ü" then followed by "äö" then its displayed correct anyone knows why?
You can read the QR Code from zxing api from below code.
binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(new FileInputStream("QR_Code.JPG")))));
result = new MultiFormatReader().decode(binaryBitmap);
System.out.println("QR Code : "+result.getText());
If you look at the developer documentation from zxing http://code.google.com/p/zxing/wiki/DeveloperNotes you will see that they expressly talk about the issue with non latin based characters.
As the QR Code standard does not define an exact way of specificing the character encoding within a QR code there recommendation is to only use characters which appear within all three standard encodings (ISO-8859-1, ISO-8859-15, UTF-8)
In the Hashtable
of hints that you pass the encoder, set EncoderHintType.CHARACTER_SET
to "UTF-8"
. Barry's answer is correct, but forcing it to try UTF-8 might happen to work better for you.
You can read the QR Code from zxing api from below code.
binaryBitmap = new BinaryBitmap(new HybridBinarizer(new BufferedImageLuminanceSource(ImageIO.read(new FileInputStream("QR_Code.JPG")))));
result = new MultiFormatReader().decode(binaryBitmap);
System.out.println("QR Code : "+result.getText());
精彩评论