Page 1 of 1

Encoding DataMatrix with Latin-2 using ECI

Posted: Wed Sep 07, 2011 11:36 am
by Document Partner
Hi,

We are a software company in Austria in the output management business.
As an international operating corporation such we are facing the interesting requirement to encode middle and east european language characters of the
German, Czech and Croatian language into datamatrix symbols.
As we only have limited control over the barcode-reader we do not have the option of encoding our data via UTF-8 or base64.
Therefor I am searching for a standard way to encode Latin-1 (which is the standard encoding of datamatrix) and Latin-2 into our symbols.

Unfortunately there is no out of the box solution supporting a "string in, bitmap out" style encoding supporting ECI that is capable of auto detecting the correct ECI-encoding of every each (text) character.

So I have 2 questions.
First is: Is the code I assembled to produce a symbol correct in the means of datamatrix standard (ISO/IEC16022:2006) and aim-standard (AIM Inc. ITS/04-001)
The code simply adds the character 0xC8 to "some leading text" and creates a symbol out of that.

Code: Select all

      var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter ();
      barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DataMatrix;
      barcodeWriter.Settings.ProcessSpecialSymbols = true;

      var eciCharacterValueItem = NonDataFlags.CreateECICharacter (4);

      var encoding = Encoding.GetEncoding (1250);   //windows-1250 is Latin-2 equivalent
      var bytes = encoding.GetBytes ("Č");
      var encodedString = new string (bytes.Select (x => (char)x).ToArray ());

      var hacekC = new DataMatrixTextValueItem (encodedString, DataMatrixEncodingMode.Text);

      barcodeWriter.Settings.ValueItems = new ValueItemBase[] { new DataMatrixTextValueItem ("some leading text", DataMatrixEncodingMode.Text), eciCharacterValueItem, hacekC };
      var outputImage = barcodeWriter.GetBarcodeAsBitmap ();
Second question is:
Will there ever be a possibilty to read generated ECI-symbol with todays available barcode readers or Libraries?
I mean I could now of course write some code to decode the above generated symbol and get the correct output for any input string that is in Latin-1 or Latin-2 (even mixed).
But since I do not know how the codes will be processed by our customer in future appliances I would need a standard conformant way of encoding/decoding symbols.
Since I made that code up for myself and I have not found anything comparable I at least need the safety to say:
We are encoding that right and all other problems in reading occur of non-conformant scanners/libraries.

kind regards,
Roman Brandstetter

Re: Encoding DataMatrix with Latin-2 using ECI

Posted: Thu Sep 08, 2011 3:32 pm
by Document Partner
Hi,

Alright I did now find out, that

Code: Select all

new string()
does not work with all values from 0 to 255 in a character array. So the code would more or like look like this:

Code: Select all

      var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter ();
      barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DataMatrix;
      barcodeWriter.Settings.ProcessSpecialSymbols = true;

      var eciCharacterValueItem = NonDataFlags.CreateECICharacter (4);

      var encoding = Encoding.GetEncoding (1250);   //windows-1250 is Latin-2 equivalent
      var bytes = encoding.GetBytes ("Č");

      var hacekC = new BinaryValueItem (bytes);

      barcodeWriter.Settings.ValueItems = new ValueItemBase[] { new DataMatrixTextValueItem ("some leading text", DataMatrixEncodingMode.Text), eciCharacterValueItem, hacekC };
      var outputImage = barcodeWriter.GetBarcodeAsBitmap ();
Questions are still the same.

kind regards,
Roman Brandstetter MSc

Re: Encoding DataMatrix with Latin-2 using ECI

Posted: Thu Sep 08, 2011 4:30 pm
by Yuri
1. Yes, your code looks corect, meaning your first message.

2. According to the specification ISO/IEC16022:2006 decoding(encoding) of text is a task of Application software, barcode reader just gives the information on how the data should be interpret.

For that purpose our barcode reader uses the ECICharacterValueItem class. Any third party scanners or libraries should be able to give the information to the application that there are present some ECI characters in data stream, and Application software must interpet this information (apply encoding).

Code: Select all

// generate
var barcodeWriter = new BarcodeWriter();
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DataMatrix;

var eciCharacterValueItem = NonDataFlags.CreateECICharacter(4);

var encoding = Encoding.GetEncoding(1250);   //windows-1250 is Latin-2
equivalent
var bytes = encoding.GetBytes("Č");
var encodedString = new string(bytes.Select(x => (char)x).ToArray());

var hacekC = new DataMatrixTextValueItem(encodedString,
DataMatrixEncodingMode.Text);

barcodeWriter.Settings.ValueItems = new ValueItemBase[] { new
DataMatrixTextValueItem("some leading text", DataMatrixEncodingMode.Text),
eciCharacterValueItem, hacekC };
var outputImage = barcodeWriter.GetBarcodeAsBitmap();


// TEST (read)
var barcodeReader = new BarcodeReader();
barcodeReader.Settings.ScanBarcodeTypes = barcodeWriter.Settings.Barcode;

IBarcodeInfo barcodeInfo = barcodeReader.ReadBarcodes(outputImage)[0];

var valueItems = barcodeInfo.ValueItems;

string value = valueItems[0].ToString();

if (((ECICharacterValueItem)valueItems[1]).ECIAssignmentNumber == 4)
{
    bytes = valueItems[2].ToString().ToCharArray().Select(x =>
(byte)x).ToArray();
    value += encoding.GetString(bytes);
}

--
Sincerely, Yuri

Re: Encoding DataMatrix with Latin-2 using ECI

Posted: Fri Sep 09, 2011 2:09 pm
by Document Partner
hi,

Thanks for your reply.
So now I know I'm on the right way.

I have one question left.
In the AIM-Standard for ECI (page 34) there is a DataMatrix tag containing greek characters.
If you don't have the standard, there is a draft version here: http://www.aimglobal.org/standards/symb ... pubrev.pdf
that contains the exact same picture.
A part of the input string looks like the following:
"Irritating to eyes and skin/Ερεθίζει τα μάτια και το δέρμα/\\"

When I decode the picture using bctester http://www.bctester.de/ I get the following output for the part with the greek characters:
"Irritating to eyes and skin/\\000009Åñåèßæåé ôá ìÜôéá êáé ôï äÝñìá /\\000003\\\\\"
when I try to encode the same input string (using ECI) with the VintaSoft library I get the following output:
"]d4*DEMO*Irritating to eyes and skin/\000009Åñåèßæåé ôá ìÜôéá êáé ôï äÝñìá/\000003\\\\"

The code I am using to reproduce this encoding is the following:

Code: Select all

      var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter ();
      barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.DataMatrix;
      barcodeWriter.Settings.ProcessSpecialSymbols = true;

      var valueItems = GetEncodedValueItemsVintaSoft (dataInput);

      //latin-7 iso-8859-7 according to http://msdn.microsoft.com/en-us/library/system.text.encodinginfo.getencoding%28VS.80%29.aspx
      var greekEncoding = Encoding.GetEncoding (28597);

      barcodeWriter.Settings.ValueItems = new ValueItemBase[] {
          new TextValueItem ("Irritating to eyes and skin/"),
          NonDataFlags.CreateECICharacter(9),
          new BinaryValueItem (greekEncoding.GetBytes ("Ερεθίζει τα μάτια και το δέρμα/")),
          NonDataFlags.CreateECICharacter(3),
          new TextValueItem ("\\\\")
        };

      var outputImage = barcodeWriter.GetBarcodeAsBitmap ();
As you can see there are some backslashes missing in the output. (before the ECI-characters and after the 3 at the latch to latin-1)
I tried to add the backslashes in the text but then the output also does not look as in the sample of the AIM standard:
]d4*DEMO*Irritating to eyes and skin/\\000009Åñåèßæåé ôá ìÜôéá êáé ôï äÝñìá/\\\000003\\\\

here is the code:

Code: Select all

      //...

      barcodeWriter.Settings.ValueItems = new ValueItemBase[] {
          new TextValueItem ("Irritating to eyes and skin/\\"),
          NonDataFlags.CreateECICharacter(9),
          new BinaryValueItem (greekEncoding.GetBytes ("Ερεθίζει τα μάτια και το δέρμα/\\")),
          NonDataFlags.CreateECICharacter(3),
          new TextValueItem ("\\\\")
        };

      //this also does not work as expected
      barcodeWriter.Settings.ValueItems = new ValueItemBase[] {
          new TextValueItem ("Irritating to eyes and skin/\\"),
          NonDataFlags.CreateECICharacter(9),
          new BinaryValueItem (greekEncoding.GetBytes ("Ερεθίζει τα μάτια και το δέρμα/")),
          new TextValueItem ("\\"),
          NonDataFlags.CreateECICharacter(3),
          new TextValueItem ("\\\\")
        };

      //...
My question is now:
Am I supposed to add these backslash characters as a part of the ECI encoding procedure (then how should I add them correctly) or should this actually be done by the library.
Both of whick is OK for me, but I'm just trying to find out if this is an issue in the library that I'm trying to work around (which could be changed by your developers any time)
or if this is a wanted and specified behaviour on which I can trust that it won't be changed in the near future.

Anyways I need to know how the code should be changed on my side to reproduce this (probably standard-conformant) tag of the AIM standard.
Because it would be neccessary to encode such a text to be AIM standard conformant.

kind regards,
Roman Brandstetter MSc

Re: Encoding DataMatrix with Latin-2 using ECI

Posted: Mon Sep 12, 2011 9:52 am
by Document Partner
hi,

Ok, as it turns out this sample is part of a much bigger, more complicated example that includes pseudo transformation ecis and so on.
Unfortunately there is no easier test-tag available that includes ECIs.
So you can ignore the last message.

Btw. Great job guys.
I've tested a lot of 2D barcode libraries (more than ten) and yours is by far the most outstanding.

kind regards,
Roman Brandstetter