How to Read Code 39 Barcodes in C#

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

When it comes to inventory, logistics, and industrial applications, you need a reliable and widely compatible barcode. One of the most popular and versatile options is Code 39. A Code 39 barcode is a popular barcode format that can vary in length.

The original Standard Code 39 is capable of encoding uppercase letters (A-Z), digits (0-9), and a handful of special characters (like space, -, $, +, %, and .). This was great for basic IDs, but modern needs often require encoding all 128 ASCII characters. For this, the Code 39 Extended specification was created.

In this how-to, we'll show you how to easily read both the standard and extended variations of Code 39 with IronBarcode.

Get started with IronBarcode

Nutzen Sie IronBarcode heute kostenlos in Ihrem Projekt.

Erster Schritt:
green arrow pointer



Reading Standard Code 39 Barcode

Reading a Code 39 barcode is straightforward with IronBarcode. We first initialize a new BarcodeReaderOptions and specify the barcode type, which is BarcodeEncoding.Code39. This step optimizes the reader by telling it exactly what kind of barcode to look for.

Afterwards, we read the barcodes using the Read method, passing the barcode image and the options variable as parameters. We then iterate over the results collection and print the string value of each barcode to the console.

Input Barcode Image

This image contains a standard Code 39 barcode.

Standard Code 39 barcode

Code

:path=/static-assets/barcode/content-code-examples/how-to/read-code39-barcode.cs
using IronBarCode;
using System;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Tell the reader to only look for Code 39.
    ExpectBarcodeTypes = BarcodeEncoding.Code39
};

// Read barcode(s) from the image file using the specified options
var results = BarcodeReader.Read("code39.png", options);

// Loop through each BarcodeResult found in the image
foreach (var result in results)
{
    // Print the decoded string value of the standard Code 39 barcode
    Console.WriteLine(result.ToString());
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Standard Code39 Output

Reading Extended Code 39 Barcode

Reading an extended Code 39 barcode is quite similar to its standard counterpart. The main difference is that we must set the UseCode39ExtendedMode property to true.

This setting instructs IronBarcode to interpret the special character pairs (e.g., +T, %O) and decode them into their proper full-ASCII equivalents (e.g., t, !).

Input Barcode Image

This image contains an extended Code 39 barcode. The value Test-Data! contains lowercase characters and an exclamation mark, which are only available in the full ASCII set and require extended mode.

Extended Code39

Code

:path=/static-assets/barcode/content-code-examples/how-to/read-extended-code39-barcode.cs
using IronBarCode;
using System;

BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    // Enable extended Code 39 mode
    UseCode39ExtendedMode = true,

    // Specify that we are expecting Code 39 barcodes
    ExpectBarcodeTypes = BarcodeEncoding.Code39
};

// Read barcode(s) from the extended code 39 image
var results = BarcodeReader.Read("code39extended.png", options);

// Loop through each BarcodeResult found in the image
foreach (var result in results)
{
    // Print the fully decoded ASCII string (e.g., "Test-Data!")
    Console.WriteLine(result.ToString());
}
IRON VB CONVERTER ERROR developers@ironsoftware.com
$vbLabelText   $csharpLabel

Output

Extended Code39 Output

Tipps The console output may not properly display all ASCII characters. In those scenarios, please pipe the output to a .txt file to verify the extracted result.

Häufig gestellte Fragen

Was ist ein Code-39-Barcode?

Code 39 ist ein gängiges Barcode-Format, das in der Lagerverwaltung, Logistik und in industriellen Anwendungen eingesetzt wird. Es kann Großbuchstaben, Ziffern und einige Sonderzeichen kodieren. Es gibt auch eine erweiterte Version, die alle 128 ASCII-Zeichen unterstützt.

Wie kann ich Code-39-Barcodes in C# lesen?

Sie können Code-39-Barcodes in C# mithilfe der IronBarcode-Bibliothek lesen. Initialisieren Sie ein `BarcodeReaderOptions`-Objekt, geben Sie `BarcodeEncoding.Code39` an und verwenden Sie die `Read`-Methode, um die Barcode-Daten zu extrahieren.

Was benötige ich, um mit IronBarcode Code-39-Barcodes lesen zu können?

Laden Sie zunächst die IronBarcode C#-Bibliothek von NuGet herunter. Initialisieren Sie anschließend ein BarcodeReaderOptions-Objekt und geben Sie den Barcode-Typ als Code39 an.

Worin besteht der Unterschied zwischen Standard- und erweitertem Code 39?

Der Standardcode 39 kann Großbuchstaben, Ziffern und einige Sonderzeichen kodieren, während der erweiterte Code 39 den gesamten Satz von 128 ASCII-Zeichen durch die Verwendung spezieller Zeichenpaare unterstützt.

Wie lese ich einen erweiterten Code-39-Barcode mit IronBarcode?

Um einen erweiterten Code-39-Barcode zu lesen, setzen Sie die Eigenschaft „UseCode39ExtendedMode“ in IronBarcode auf „true“. Dadurch kann die Bibliothek den vollständigen ASCII-Zeichensatz dekodieren.

Welche Rolle spielen BarcodeReaderOptions in IronBarcode?

Mit BarcodeReaderOptions in IronBarcode können Sie den Typ des zu lesenden Barcodes festlegen und so den Lesevorgang optimieren, indem Sie sich auf das angegebene Format konzentrieren.

Kann IronBarcode sowohl Standard- als auch erweiterte Code-39-Barcodes lesen?

Ja, IronBarcode kann sowohl Standard- als auch erweiterte Code-39-Barcodes lesen. Stellen Sie bei erweiterten Barcodes sicher, dass die Eigenschaft „UseCode39ExtendedMode“ auf „true“ gesetzt ist.

Unterstützt IronBarcode Sonderzeichen in Code-39-Barcodes?

Ja, IronBarcode unterstützt Sonderzeichen in Code-39-Barcodes. Die Standardversion unterstützt einige wenige Sonderzeichen, während die erweiterte Version alle ASCII-Zeichen unterstützt.

Was ist erforderlich, um den vollständigen ASCII-Zeichensatz in Code-39-Barcodes zu dekodieren?

Um den vollständigen ASCII-Zeichensatz in Code-39-Barcodes zu dekodieren, müssen Sie die erweiterte Version verwenden und die Eigenschaft UseCode39ExtendedMode in IronBarcode auf true setzen.

Kann IronBarcode mit Bilddateien zum Auslesen von Barcodes arbeiten?

Ja, IronBarcode kann Barcodes aus Bilddateien lesen. Sie übergeben das Barcode-Bild zusammen mit den BarcodeReaderOptions an die Read-Methode, um die Daten zu extrahieren.

Curtis Chau
Technischer Autor

Curtis Chau hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender ...

Weiterlesen
Bereit anzufangen?
Nuget Downloads 1,935,276 | Version: 2025.11 gerade veröffentlicht