# GS1-128
## Does IronBarcode Support GS1 UCC/EAN-128 Symbology?
Barcodes with GS1 are recognized and decoded accurately. However, the issue lies in the current lack of brackets in the displayed barcode value.
When using GS1-128, IronBarcode currently outputs: `01950123456789033103000123` (which is recognized as a Code 128 barcode with GS1 signature). The desired value to be displayed on the image output would be: `01950123456789033103000123`. However, the barcode scanner will output `(01)95012345678903(3103)000123` with a detection of the barcode type as `Code128`.
For generating a GS1-128 barcode, use the following code:
```csharp
using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
```
### Output barcode

The above code generates a GS1-128 barcode with a default divider. If you want to add additional dividers, you can insert the Unicode separator `\u00f1`. However, note that when using the `AddBarcodeValueTextBelowBarcode` method, the Unicode character ñ (code 0x00F1) will be displayed. To overcome this limitation, an alternative approach is to manipulate the string and pass the modified value to the `AddAnnotationTextBelowBarcode` method. This way, you can achieve the desired display of the barcode value without the ñ character.
```csharp
using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
```
### Output barcode

When scanning the barcode, the output will be `(01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000`, and the barcode type will be detected as `GS1Code128`.
## Analyze GS1-128 Encoding
IronBarcode can also analyze the physical encoding of a GS1-128 barcode, showing which Code 128 character sets (A, B, or C) are used for each segment of the data. Use the `Code128GS1Parser.ParseWithEncoding` method to parse a GS1 string with encoding analysis included.
```csharp
using IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // true
```
Since GS1-128 data is primarily numeric, the encoder uses Code C for maximum compactness. The `HasEncodingInfo` property confirms that encoding analysis is available on the result.
Does IronBarcode Support GS1 UCC/EAN-128 Symbology?
Barcodes with GS1 are recognized and decoded accurately. However, the issue lies in the current lack of brackets in the displayed barcode value.
When using GS1-128, IronBarcode currently outputs: 01950123456789033103000123 (which is recognized as a Code 128 barcode with GS1 signature). The desired value to be displayed on the image output would be: 01950123456789033103000123. However, the barcode scanner will output (01)95012345678903(3103)000123 with a detection of the barcode type as Code128.
For generating a GS1-128 barcode, use the following code:
using IronBarCode;class BarcodeExample{ static voidMain() { // Create a GS1-128 barcode using the specified value GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1); // Add the barcode value text below the barcode on the generated image barcode.AddBarcodeValueTextBelowBarcode(); // Save the barcode image as a PNG file barcode.SaveAsPng("gs1code128.png"); }}
using IronBarCode;
class BarcodeExample
{
static void Main()
{
// Create a GS1-128 barcode using the specified value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);
// Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode();
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
ImportsIronBarCodeFriend Class BarcodeExampleShared Sub Main() ' Create a GS1-128 barcode using the specified value Dim barcode AsGeneratedBarcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1) ' Add the barcode value text below the barcode on the generated image barcode.AddBarcodeValueTextBelowBarcode() ' Save the barcode image as a PNG file barcode.SaveAsPng("gs1code128.png") End SubEnd Class
Imports IronBarCode
Friend Class BarcodeExample
Shared Sub Main()
' Create a GS1-128 barcode using the specified value
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1)
' Add the barcode value text below the barcode on the generated image
barcode.AddBarcodeValueTextBelowBarcode()
' Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png")
End Sub
End Class
Output barcode
The above code generates a GS1-128 barcode with a default divider. If you want to add additional dividers, you can insert the Unicode separator \u00f1. However, note that when using the AddBarcodeValueTextBelowBarcode method, the Unicode character ñ (code 0x00F1) will be displayed. To overcome this limitation, an alternative approach is to manipulate the string and pass the modified value to the AddAnnotationTextBelowBarcode method. This way, you can achieve the desired display of the barcode value without the ñ character.
using IronBarCode;class BarcodeExampleWithAnnotation{ static voidMain() { // Original barcode value string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000"; // Remove unwanted unicode characters for display purposes string trimmedString = barcodeValue.Replace("\u00f1", ""); // Create a GS1-128 barcode using the original value GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1); // Add a custom annotation text below the barcode with the trimmed value barcode.AddAnnotationTextBelowBarcode(trimmedString); // Save the barcode image as a PNG file barcode.SaveAsPng("gs1code128.png"); }}
using IronBarCode;
class BarcodeExampleWithAnnotation
{
static void Main()
{
// Original barcode value
string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";
// Remove unwanted unicode characters for display purposes
string trimmedString = barcodeValue.Replace("\u00f1", "");
// Create a GS1-128 barcode using the original value
GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);
// Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString);
// Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png");
}
}
ImportsIronBarCodeClass BarcodeExampleWithAnnotationShared Sub Main() ' Original barcode value Dim barcodeValue AsString = "0195012345678903310300012300" & ChrW(&HF1) & "000000123300000" & ChrW(&HF1) & "0000012312300000" ' Remove unwanted unicode characters for display purposes Dim trimmedString AsString = barcodeValue.Replace(ChrW(&HF1), "") ' Create a GS1-128 barcode using the original value Dim barcode AsGeneratedBarcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1) ' Add a custom annotation text below the barcode with the trimmed value barcode.AddAnnotationTextBelowBarcode(trimmedString) ' Save the barcode image as a PNG file barcode.SaveAsPng("gs1code128.png") End SubEnd Class
Imports IronBarCode
Class BarcodeExampleWithAnnotation
Shared Sub Main()
' Original barcode value
Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&HF1) & "000000123300000" & ChrW(&HF1) & "0000012312300000"
' Remove unwanted unicode characters for display purposes
Dim trimmedString As String = barcodeValue.Replace(ChrW(&HF1), "")
' Create a GS1-128 barcode using the original value
Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1)
' Add a custom annotation text below the barcode with the trimmed value
barcode.AddAnnotationTextBelowBarcode(trimmedString)
' Save the barcode image as a PNG file
barcode.SaveAsPng("gs1code128.png")
End Sub
End Class
Output barcode
When scanning the barcode, the output will be (01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000, and the barcode type will be detected as GS1Code128.
Analyze GS1-128 Encoding
IronBarcode can also analyze the physical encoding of a GS1-128 barcode, showing which Code 128 character sets (A, B, or C) are used for each segment of the data. Use the Code128GS1Parser.ParseWithEncoding method to parse a GS1 string with encoding analysis included.
using IronBarCode;// GS1-128 with encoding analysisvar gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");Console.WriteLine(gs1Result.CharacterSetSummary); // "C"Console.WriteLine(gs1Result.HasEncodingInfo); // true
using IronBarCode;
// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary); // "C"
Console.WriteLine(gs1Result.HasEncodingInfo); // true
Imports IronBarCode
' GS1-128 with encoding analysis
Dim gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003")
Console.WriteLine(gs1Result.CharacterSetSummary) ' "C"
Console.WriteLine(gs1Result.HasEncodingInfo) ' True
Since GS1-128 data is primarily numeric, the encoder uses Code C for maximum compactness. The HasEncodingInfo property confirms that encoding analysis is available on the result.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.