Hi, mio.kazuhisa
We have improved the Unicode character encoding for 2D barcodes starting from version 24.5 of Aspose.BarCode to optimize the data stream and reduce the barcode size. The issue you’re encountering stems from the fact that the character “×” can be encoded as the byte “D7” in the default QR encoding standard ISO/IEC 8859-1. To minimize the barcode’s size, this character is now encoded as a single byte “D7” instead of two bytes as it was in earlier versions.
To customize the encoding of Unicode characters in your QR code, you can try one of the following four options:
- Using UTF-8 Encoding with ECI Mode. Set the following parameters:
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, code);
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ECI;
generator.Parameters.Barcode.QR.QrECIEncoding = ECIEncodings.UTF8;
generator.Save("filename.png");
In this case, the codetext will first be converted to a byte stream using UTF-8 encoding and then compressed. The character “×” will be encoded similarly to version 22.12, but an ECI identifier will be added to the beginning of the data stream.
- Using Shift_JIS Encoding with ECI Mode. Set the following parameters:
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR, code);
generator.Parameters.Barcode.QR.QrEncodeMode = QREncodeMode.ECI;
generator.Parameters.Barcode.QR.QrECIEncoding = ECIEncodings.Shift_JIS;
generator.Save("filename.png");
Here, the codetext will be converted into a byte stream using the S-JIS encoding and then compressed. The character “×” will be encoded differently from version 22.12, but this approach might suit your requirements better. The ECI identifier will also be inserted before the data stream.
- Using SetCodeText with UTF-8 Encoding.
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR);
generator.SetCodeText(code, Encoding.UTF8);
generator.Save("filename.png");
In this case, the codetext will be encoded in UTF-8 and compressed similarly to version 22.12. A UTF-8 Byte Order Mark (EF BB BF) will be inserted before the data stream.
- Using SetCodeText and GetCodeText with S-JIS Encoding.
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR);
generator.SetCodeText(code, Encoding.GetEncoding(932)); // S-JIS encoding
Bitmap bitmap = generator.GenerateBarCodeImage();
The codetext will be converted to a byte stream using the S-JIS encoding and then compressed. However, to retrieve the correct data, you’ll need to use the GetCodeText method on the reader side:
using (BarCodeReader reader = new BarCodeReader(bitmap, DecodeType.QR))
{
reader.ReadBarCodes();
Console.WriteLine(reader.FoundBarCodes[0].GetCodeText(Encoding.GetEncoding(932)));
}
Please try these methods and let us know if you need further assistance.