IndexOutOfBoundsException with german umlauts

Questions, comments and suggestions concerning VintaSoft Barcode .NET SDK.

Moderator: Alex

Post Reply
Document Partner
Posts: 13
Joined: Wed Sep 07, 2011 11:16 am

IndexOutOfBoundsException with german umlauts

Post by Document Partner »

Hi,

I get an exception " Index was outside the bounds of the array." when trying to encode an Aztec symbol with german umlauts.
Here is the C# code I am using:

Code: Select all

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

      var valueItems = new List<ValueItemBase> ();
      valueItems.Add (new TextValueItem (@"German
  AÄBCDEFGHIJKLMNOÖPQRSßTUÜVWXYZ
  aäbcdefghijklmnoöpqrsßtuüvwxyz"));

      barcodeWriter.Settings.ValueItems = valueItems.ToArray ();
      var outputImage = barcodeWriter.GetBarcodeAsBitmap ();

      return outputImage;
kind regards,
Roman Brandstetter
Yuri
Posts: 64
Joined: Wed Jul 23, 2008 2:47 pm

Re: IndexOutOfBoundsException with german umlauts

Post by Yuri »

Hi,

TextValueItem may contain only symbols which are allowed for encoding in text mode.

The symbols like Ä, Ö, Ü and ß should be encoded in binary mode.

Utilize automatic selection of encoding mode by setting barcodeWriter.Settings.Value property at necessary value.

The following code illustrate how your text is automatically devided on 17 items for its correct encoding further:

Code: Select all

var barcodeWriter = new Vintasoft.Barcode.BarcodeWriter();
barcodeWriter.Settings.Barcode = Vintasoft.Barcode.BarcodeType.Aztec;

barcodeWriter.Settings.Value =
"GermanAÄBCDEFGHIJKLMNOÖPQRSßTUÜVWXYZaäbcdefghijklmnoöpqrsßtuüvwxyz";
var outputImage = barcodeWriter.GetBarcodeAsBitmap();

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

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

if (barcodeWriter.Settings.Value != barcodeInfo.Value)
    throw new ArgumentException();

foreach (ValueItemBase valueItem in barcodeInfo.ValueItems)
    Console.WriteLine(string.Format("[{0}] {1}", valueItem.GetType().Name,
valueItem));
--
Sincerely, Yuri
Document Partner
Posts: 13
Joined: Wed Sep 07, 2011 11:16 am

Re: IndexOutOfBoundsException with german umlauts

Post by Document Partner »

Hi,

Thanks for the info. The Code is working now.

kind regards,
Roman
Post Reply