Error while reading barcode

Hi

we’re facing some decoding error while reading from a barcode.
the barcode perhaps represents UTF-8 and has a word
Spłata

the output we read from API is : Spłata (BarCodeReader --> getCodeText())
what may be causing this?..am missing something or is it inherent to API?

need a fix/ suggestions please

Thanks!

Hi,

Thanks for considering Aspose.

Please refer to the article at http://www.aspose.com/documentation/java-components/aspose.barcode-for-java/how-to-generate-and-recognize-barcodes-for-utf8-unicode-characters.html and use Aspose.BarCode for Java 2.1 to generate/recognize the barcode. You need to use “UTF-8” encoding for that. I am also attaching the sample program.

Hi
Thanks for response!..perhaps it was fault on my part for not delivering a correct message.
The barcode is a DataMatrix (have attached it)…it has a word Spłata (pls notice the crossed “l” …that’s Polish character)…now when i decode it using Aspose…the other characters are read correctly but this ł is not…and the output of program is SpÅ?ata

any insight on what may be wrong in this?..had already tried with the solution you posted!

thanks!

Hi,

Thanks for posting the image. I also got junk character instead of the Polish letter “ł”, when tried to read barcode from the posted image. Could you please tell us how this image is generated (using Aspose or other library, any specific settings etc)? Could you please also post the sample program in case you generated the barcode using Aspose?

On the other hand, if I do both generation and recognition using Aspose, the generated image is different using the default settings. And the Polish character is also recognized correctly.


am not aware of the source of image (rather, source of encoding :slight_smile: )…will track that down and respond as quick as can…
thanks for help…would you please be able to direct me to a link that shall contain info on what sources of encoding does Aspose barcode API support, that shall help us quickly analyze and decide upon its productive use!
thanks yet again!

Hi,

The sample code is attached to generate and recognize the datamatrix barcode that contains the Polish character.

Regarding encoding, I meant the encoding of the codetext (the string) that contains the unicode or UTF-8 characters. In the example that I posted, I used UTF-8 encoding.

Hi,

Could you please try the method below (replace with below) for recognizing the image posted by you.


private static String getUnicodeFromCodeText(String cs) throws UnsupportedEncodingException {
byte[] bs = new byte[cs.length()];
for(int i=0; i< cs.length();i++)
{
char c = cs.charAt(i);
//if(c < 128)
if(c < 256)
{
bs[i] = (byte) c;
}
else
{
//bs[i] = (byte) (127 - c);
bs[i] = (byte) (255 - c);
}
}
return new String(bs,“UTF-8”);
}

works a treat!!..thanks!..
what encoding does that image follow…why a depth of 256? is that an AES-256 code?..do we need to have different identifications and post-processing for AES-128, AES-192 and AES-256?

Hi,


The encoding is actually related to the characters in the codetext string. For example, a UTF-8 character consists of 8bits (2 ^ 8 = 256). I just tested with 8 bit encoding to check if the image used this method and it worked for your image. However, we used (2 ^ 7 = 128) 7 bits for one character.

It is not related with AES. It’s related character to byte conversion.

Thanks for insight Saqib! that helped.

when i am generating the QR barcode type by setting setCodeTextVisible(true) ,it is displaying junk characters below the barcode image in the code text.I am using Java 2.1 as told by you.
Code Text that needs to be displayed : 529||中文 中國話

<br>

Hi Kiran,


The junk characters are displayed due to the encoding. Please try the following workaround:

builder.setCodeTextVisible(false); // do not display the codetext using this statement
builder.setCaptionBelow(new Caption(strOriginalCodetext)); // use this statement to display the codetext below the image (without encoding)