IronBarcode 操作指南 读取 Code 39 条形码 How to Read Code 39 Barcodes in C# Curtis Chau 已更新:十一月 19, 2025 Download IronBarcode NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article 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 今天在您的项目中使用 IronBarcode,免费试用。 第一步: 免费开始 How to Read Code 39 Barcodes in C# Download the IronBarcode C# library to read Code39 barcodes Initialize a new BarcodeReaderOptions Specify BarcodeEncoding.Code39 in the options Read the Code 39 barcode with Read Verify the results and print them out to the console 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. 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 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. 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 提示 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. 常见问题解答 什么是Code 39条形码? Code 39 是一种广泛应用于库存管理、物流和工业领域的条形码格式。它可以编码大写字母、数字和一些特殊字符。此外,它还有一个扩展版本,支持全部 128 个 ASCII 字符。 如何在 C# 中读取 Code 39 条形码? 您可以使用 IronBarcode 库在 C# 中读取 Code 39 条形码。初始化 BarcodeReaderOptions 对象,指定 BarcodeEncoding.Code39,然后使用 Read 方法提取条形码数据。 我需要哪些设备才能开始使用 IronBarcode 读取 Code 39 条形码? 首先,从 NuGet 下载 IronBarcode C# 库。然后,初始化一个 BarcodeReaderOptions 对象,并将条形码类型指定为 Code39。 标准代码39和扩展代码39有什么区别? 标准代码 39 可以编码大写字母、数字和一些特殊字符,而扩展代码 39 通过使用特殊字符对支持全部 128 个 ASCII 字符。 如何使用 IronBarcode 读取扩展的 Code 39 条形码? 要读取扩展的 Code 39 条形码,请在 IronBarcode 中将 UseCode39ExtendedMode 属性设置为 true。这样,库就可以解码完整的 ASCII 字符集。 IronBarcode 中 BarcodeReaderOptions 的作用是什么? IronBarcode 中的 BarcodeReaderOptions 允许您指定要读取的条形码类型,通过专注于指定的格式来优化读取过程。 IronBarcode 可以读取标准 Code 39 条形码和扩展 Code 39 条形码吗? 是的,IronBarcode 可以读取标准 Code 39 条码和扩展 Code 39 条码。对于扩展 Code 39 条码,请确保将 UseCode39ExtendedMode 属性设置为 true。 IronBarcode 是否支持 Code 39 条形码中的特殊字符? 是的,IronBarcode支持Code 39条形码中的特殊字符。标准版支持部分特殊字符,而扩展版支持所有ASCII字符。 要解码 Code 39 条形码中的完整 ASCII 码集,需要哪些条件? 要解码 Code 39 条形码中的完整 ASCII 码集,您必须使用扩展版本,并在 IronBarcode 中将 UseCode39ExtendedMode 属性设置为 true。 IronBarcode 是否能够处理用于条形码读取的图像文件? 是的,IronBarcode 可以从图像文件中读取条形码。您需要将条形码图像和 BarcodeReaderOptions 参数传递给 Read 方法才能提取数据。 Curtis Chau 立即与工程团队聊天 技术作家 Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。 准备开始了吗? Nuget 下载 1,935,276 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,935,276 查看许可证