GS1-128

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronBarcode は GS1 UCC/EAN-128 シンボルをサポートしていますか?

GS1 のバーコードは正確に認識され、デコードされます。 しかし、表示されるバーコードの値に括弧が欠けているという問題があります。

GS1-128を使用する場合、IronBarcodeは現在次のように出力します:01950123456789033103000123(これはGS1シグネチャ付きのCode 128 BARCODEとして認識されます)。 画像出力に表示されるべき値は、01950123456789033103000123となります。 ただし、バーコードスキャナーは、バーコードの種類を Code128 と検出した場合、(01)95012345678903(3103)000123 を出力します。

GS1-128 バーコードを生成するには、次のコードを使用します。

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");
    }
}
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");
    }
}
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
$vbLabelText   $csharpLabel

出力バーコード

BarCode出力例

上記のコードは、デフォルトの区切りを持つ GS1-128 バーコードを生成します。 区切り線を追加したい場合は、Unicode区切り文字 \u00f1 を挿入してください。 ただし、AddBarcodeValueTextBelowBarcode メソッドを使用する場合、Unicode 文字 ñ(コード 0x00F1)が表示される点にご注意ください。 この制限を克服するための代替アプローチとして、文字列を操作し、変更後の値を AddAnnotationTextBelowBarcode メソッドに渡す方法があります。 この方法により、ñ 文字を含まないバーコード値の希望通りの表示を達成できます。

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");
    }
}
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");
    }
}
Imports IronBarCode

Friend Class BarcodeExampleWithAnnotation
	Shared Sub Main()
		' Original barcode value
		Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&H00f1).ToString() & "0000000123300000" & ChrW(&H00f1).ToString() & "0000012312300000"

		' Remove unwanted unicode characters for display purposes
		Dim trimmedString As String = barcodeValue.Replace(ChrW(&H00f1).ToString(), "")

		' 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
$vbLabelText   $csharpLabel

出力バーコード

注釈付きBARCODEの出力例

BARCODEをスキャンすると、出力は (01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000 となり、BARCODEの種類は GS1Code128 として検出されます。

GS1-128エンコーディングの分析

IronBarcodeは、GS1-128バーコードの物理的なエンコーディングを分析し、データの各セグメントでどのCode 128文字セット(A、B、またはC)が使用されているかを表示することもできます。 エンコーディング解析を含むGS1文字列を解析するには、Code128GS1Parser.ParseWithEncoding メソッドを使用してください。

using IronBarCode;

// GS1-128 with encoding analysis
var 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
$vbLabelText   $csharpLabel

GS1-128データは主に数値であるため、エンコーダーは最大限のコンパクトさを実現するためにコードCを使用します。 HasEncodingInfo プロパティは、結果に対してエンコーディング解析が利用可能であることを確認します。

カーティス・チャウ
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はできましたか?
Nuget ダウンロード 2,169,908 | バージョン: 2026.4 リリース
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package BarCode
サンプルを実行する 文字列が BarCode になるのを見る。