VintaSoft Barcode .NET SDK Discussions

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

Board index < VintaSoft Barcode < VintaSoft Barcode .NET SDK Discussions

We are migrating to new forums engine, no new registration or posting currently available. TIA for your patience.

IndexOutOfBoundsException with german umlauts



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:
      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


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:
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


Re: IndexOutOfBoundsException with german umlauts

Post by Document Partner »

Hi,

Thanks for the info. The Code is working now.

kind regards,
Roman


Page 1 from 1: 1