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.
The issue is most likely related to how some barcode readers handle ECI and character interpretation. In particular, certain scanners may not correctly interpret the ECI mode and may display unexpected characters.
For reference, the same QR code is recognized correctly in the VintaSoft demo when the InterpretECICharacters option is enabled:
https://demos.vintasoft.com/AspNetCoreBarcodeAdvancedDemo/
vintasoft_modes.png (117.2 KB)
As a workaround, you can try encoding the text explicitly as a UTF-8 byte stream when generating the QR code:
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);
generator.SetCodeText(qrText, Encoding.UTF8);
generator.Parameters.Barcode.QR.EncodeMode = QREncodeMode.Auto;
generator.Save(@"d:\save\rec\qr_encoded.png");
qr_encoded.png (564 Bytes)
@dvtdaten
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): BARCODENET-39522
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
The workaround solves the problem, thank you.
@dvtdaten,
We are glad to hear that the suggested workaround resolved your issue. Please rest assured that we are working on addressing the issue (“BARCODENET-39522 - Incorrect Data Decoding in QR Code with ECI UTF-8 Mode”). Once we have fixed it, we will update you.
FYI: I had to change the Java code from
generator.setCodeText(text, StandardCharsets.UTF_8);
to
generator.setCodeText(text.getBytes(StandardCharsets.UTF_8));
otherwise the qr validator QR-Code Validator | EPC & Swiss QR | GrandTotal Tools fails.
@dvtdaten,
Thanks for the additinal details. It seems the line of code: generator.setCodeText(text.getBytes(StandardCharsets.UTF_8)); meets your needs by converting the text to a byte array using UTF-8 encoding. This may also help other users with similar text encoding issues.