testerws
testerws

Reputation: 21

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 = 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?

Upvotes: 2

Views: 1479

Answers (4)

Keval Trivedi
Keval Trivedi

Reputation: 1300

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());

Upvotes: 2

Pratik Butani
Pratik Butani

Reputation: 62419

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());

Upvotes: 1

Sean Owen
Sean Owen

Reputation: 66886

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.

Upvotes: 1

Barry
Barry

Reputation: 446

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)

Upvotes: 1

Related Questions