barnhill / barcodelib

C# Barcode Image Generation Library
Apache License 2.0
733 stars 238 forks source link

GS1-128 FNC1 special char throws exception #179

Open gustafcarleson opened 10 months ago

gustafcarleson commented 10 months ago

Hi, thank you for this software and your work.

When upgrading from 2.4.0 to 3.0.2 our setup for creating GS1-128 stopped working.

We prepend the FNC1 char 200 (È) to our data.

var dataToEncode = Convert.ToChar(200).ToString() + ApplicationIdentifier + Data;
var image = barcode.Encode(BarcodeStandard.Type.Code128, dataToEncode, width, height)

This however, now results in the following exception:

System.Exception: 'EC128-3: Could not insert start and code characters. Message: EC128-2: Could not determine start character.'

Something has changed in the way that the encodings are retrieved and if I insert the following changes it works

var dataToEncode = Convert.ToChar(200).ToString() + ApplicationIdentifier + Data;
var image = barcode.Encode(BarcodeStandard.Type.Code128C, dataToEncode, width, height) // Note the "C" in Code128C

Code128.cs, line 175:

entry("FNC1", "FNC1", FNC1.ToString(), "11110101110"); // Note the addition ToString() which will add char 200 (È) to the C part of the lookup table

I did not find any documentation, example or test that sheds light on this so please let me know if I should do anything different.

Thanks