QR-Code Encoding Problems

Hello!

I use Aspose.BarCode 26.1 and have problems with some currency symbols.
I tried

QREncodeMode.ECIEncoding;
ECIEncodings.UTF8;

with bad results
qrModeECI.gif (1.9 KB)

and I tried

QREncodeMode.EXTENDED;

which is a better, but also fails with some symbols
qrModeExtended.gif (1.3 KB)

How can I fix this?

Kind regards!

@dvtdaten

You’re seeing incorrect currency symbols because the characters are outside the basic ASCII range, so the QR generator needs to use an ECI (Extended Channel Interpretation) that supports Unicode.

Fix

// 1. Create a QR‑code generator
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, "Price: 123 €");

// 2. Enable ECI encoding
generator.Parameters.Barcode.QREncodeMode = QREncodeMode.ECIEncoding;   // [2]

// 3. Select an ECI that can represent the symbols (UTF‑8 works for all Unicode characters)
generator.Parameters.Barcode.ECIEncoding = ECIEncodings.UTF8;          // [3]

// 4. Generate the image / stream
generator.Save("qr.png", BarCodeImageFormat.Png);
  • QREncodeMode.ECIEncoding tells the QR generator to prepend an ECI designator and encode the data using the selected character set [2].
  • Using ECIEncodings.UTF8 provides Unicode support, allowing currency symbols such as €, £, ¥ to be encoded correctly [3].

QREncodeMode.EXTENDED handles only the extended ASCII range (0‑255), which may not include some currency symbols, so those symbols can be rendered incorrectly.

Note: The code snippet has not been executed in this environment; it is provided as a hypothesis.

@dvtdaten,

Could you please share your sample code that you are using with Aspose.BarCode 26.1. Also, share your expected barcode. We will look into it soon.

		BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, qrText);

		BaseGenerationParameters parameters = generator.getParameters();
		parameters.getBarcode().getCodeTextParameters().setLocation(CodeLocation.NONE);

		QrParameters qrParams = generator.getParameters().getBarcode().getQR();
		qrParams.setErrorLevel(QRErrorLevel.LEVEL_M);
		qrParams.setVersion(QRVersion.AUTO);
		qrParams.setEncodeMode(QREncodeMode.EXTENDED);

The text is “Here are some currency Symbols: Euro €, Dollar $, Pfund £, Yen ¥, Rupie ₹, Rubel ₽, Euro € Won ₩, Bath ฿, Schekel ₪, Dong ₫, Bitcoin ₿, Ethereum Ξ” and we expect, that all of these currency symbols can be seen in the scanned qrcode, right now some of them are flawed.

@dvtdaten,

I did test your scenario/case using the following sample code and it works Ok and as expected.


        String qrText = "Here are some currency Symbols: Euro €, Dollar $, Pfund £, Yen ¥, Rupie ₹, Rubel ₽, Euro € Won ₩, Bath ฿, Schekel ₪, Dong ₫, Bitcoin ₿, Ethereum Ξ";
        BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, qrText);

		com.aspose.barcode.generation.BaseGenerationParameters parameters = generator.getParameters();
		parameters.getBarcode().getCodeTextParameters().setLocation(com.aspose.barcode.generation.CodeLocation.NONE);

		com.aspose.barcode.generation.QrParameters qrParams = generator.getParameters().getBarcode().getQR();
		qrParams.setQrErrorLevel(com.aspose.barcode.generation.QRErrorLevel.LEVEL_M);
		qrParams.setQrVersion(com.aspose.barcode.generation.QRVersion.AUTO);
		qrParams.setQrEncodeMode(com.aspose.barcode.generation.QREncodeMode.ECI);
		
		BarCodeReader reader = new BarCodeReader(generator.generateBarCodeImage(), DecodeType.QR);
		reader.readBarCodes();
		System.out.println("Codetext: " + reader.getFoundBarCodes()[0].getCodeText());

Here is the output results.
Codetext: Here are some currency Symbols: Euro €, Dollar $, Pfund £, Yen ¥, Rupie ₹, Rubel ₽, Euro € Won ₩, Bath ฿, Schekel ₪, Dong ₫, Bitcoin ₿, Ethereum Ξ

Yes, the result from the BarCodeReader is fine. But have you tried it with an external QR-Code Reader App like QR-Scanner? Maybe the fault is there, but nevertheless I have to deal with the problem.

@dvtdaten,

Good to know that it works fine on your end now. Please feel free to write us back if you have further queries or comments.

Yes, I have tested it using the exact text on the online app Generate Barcode Online. It worked perfectly, and I was able to generate the expected barcode image. Additionally, when I used the generated image to extract the code text through the app at Read Barcodes Online, it functioned flawlessly as well.