We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Handling Characters from other Languages, Upgrade Question

In an older version of Aspose.Barcode, we would turn strings into byte arrays and them pull them in with the .SetCodeText() function like this:

BarCodeBuilder objBarCodeBuilder = new BarCodeBuilder { EncodeType = EncodeTypes.DataMatrix };
byte[] byteArray = Encoding.Unicode.GetBytes(“منحة”);

I updated to v20.3.0 and transformed my code into the following. Unfortunately it errors out on cyrillic or arabic character sets. How can I change this code to handle more character sets?

protected byte[] EncodeBarCode(string BarCodeText)
BarCodeText = “منحة”;
//BarCodeText = “42 Answer To The Ultimate Question of Life, the Universe, and Everything”;
BarcodeGenerator objBarCodeBuilder = new BarcodeGenerator(EncodeTypes.DataMatrix, BarCodeText);

 objBarCodeBuilder.Parameters.Barcode.DataMatrix.DataMatrixEncodeMode = DataMatrixEncodeMode.Full;
 objBarCodeBuilder.Parameters.Barcode.XDimension.Pixels = 2;

 imgBarcode = objBarCodeBuilder.GenerateBarCodeImage();
 MemoryStream xStream = new MemoryStream();
 imgBarcode.Save(xStream, System.Drawing.Imaging.ImageFormat.Png);

 return xStream.ToArray();



We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

BARCODENET-37435 – Arabic text raises System.NullReferenceException

Issue is related with absence of Encoding in some Datamatrix modes. As workaround you can set Encoding manually:
objBarCodeBuilder.Parameters.Barcode.DataMatrix.CodeTextEncoding = Encoding.UTF8;//can be any other

The problem is passed to the developer who works on generating.

The issues you have found earlier (filed as BARCODENET-37435) have been fixed in Aspose.BarCode for .NET v20.4. This message was posted using Bugs notification tool by ahsaniqbalsidiqui