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 » Thu Sep 08, 2011 3:19 pm

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: 56
Joined: Wed Jul 23, 2008 2:47 pm

Re: IndexOutOfBoundsException with german umlauts

Post by Yuri » Fri Sep 09, 2011 9:50 am

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 » Fri Sep 09, 2011 10:15 am

Hi,

Thanks for the info. The Code is working now.

kind regards,
Roman

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests