IronBarcode 操作指南 讀取 Code 39 BarCode 使用 C# 快速輕鬆地讀取 Code 39 條碼 Curtis Chau 更新:11月 19, 2025 下載 IronBarcode NuGet 下載 DLL 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在雙子座打開 請向 Gemini 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English 在庫存、物流和工業應用領域,你需要可靠且相容性強的條碼。 Code 39 是最受歡迎、用途最廣泛的條碼格式之一。 Code 39 條碼是一種流行的條碼格式,其長度可以變化。 原始標準代碼 39 能夠編碼大寫字母 (AZ)、數字 (0-9) 和一些特殊字元(如空格、-、$、+、% 和 .)。 這對於基本的 ID 來說很棒,但現代需求通常需要對所有 128 個 ASCII 字元進行編碼。 為此,制定了 Code 39 Extended 規範。 在本教學中,我們將向您展示如何使用 IronBarcode 輕鬆讀取 Code 39 的標準版和擴充版。 開始使用 IronBarcode 立即開始在您的項目中使用 IronBarcode 並免費試用。 第一步: 免費啟動 如何在 C# 中讀取 Code 39 條碼 下載 IronBarcode C# 庫以讀取 Code39 條碼。 初始化一個新的BarcodeReaderOptions 在選項中指定BarcodeEncoding.Code39 使用Read讀取 Code 39 條碼 驗證結果並將其列印到控制台。 讀取標準代碼 39 條碼 使用 IronBarcode 讀取 Code 39 條碼非常簡單。 我們先初始化一個新的BarcodeReaderOptions ,並指定條碼類型,即BarcodeEncoding.Code39 。 此步驟透過明確告知讀取器要尋找哪種類型的條碼來最佳化讀取器。 然後,我們使用Read方法讀取條碼,並將條碼圖像和選項變數作為參數傳遞。 然後我們遍歷結果集合,並將每個條碼的字串值列印到控制台。 輸入條碼影像 此影像包含標準 Code 39 條碼。 程式碼 :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 輸出 讀取擴充碼 39 條碼 讀取擴充的 Code 39 條碼與讀取標準 Code 39 條碼非常相似。 主要區別在於我們必須將UseCode39ExtendedMode屬性設為 true。 此設定指示 IronBarcode 解釋特殊字元對(例如,+T、%O)並將其解碼為正確的完整 ASCII 等效字元(例如,t、!)。 輸入條碼影像 此影像包含擴充的 Code 39 條碼。 值Test-Data!包含小寫字元和感嘆號,這些字元僅在完整的 ASCII 字元集中可用,並且需要擴展模式。 程式碼 :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 輸出 提示 控制台輸出可能無法正確顯示所有 ASCII 字元。 在這種情況下,請將輸出重定向到 .txt 檔案以驗證提取結果。 常見問題解答 什麼是 Code 39 BarCode? Code 39 是庫存、物流和工業應用中常用的 BarCode 格式。它可以編碼大寫字母、數字和一些特殊字符。此外,還有支援全部 128 個 ASCII 字元的擴充版本。 如何在 C# 中讀取 Code 39 BarCode? 您可以使用 IronBarcode library 在 C# 中讀取 Code 39 條碼。初始化 BarcodeReaderOptions,指定 BarcodeEncoding.Code39,並使用 Read 方法提取條碼資料。 開始使用 IronBarcode 讀取 Code 39 條碼需要什麼? 要開始使用,請從 NuGet 下載 IronBarcode C# 函式庫。然後,初始化一個 BarcodeReaderOptions 物件,並指定條碼類型為 Code39。 標準 Code 39 與延伸 Code 39 有何差異? 標準 Code 39 可以編碼大寫字母、數字和少數特殊字符,而延伸 Code 39 則透過使用特殊字符對,支援全套 128 ASCII 字元。 如何使用 IronBarcode 讀取擴展的 Code 39 條碼? 要讀取擴展的 Code 39 條碼,請在 IronBarcode 中將 UseCode39ExtendedMode 屬性設為 true。這允許庫解碼完整的 ASCII 字元集。 BarcodeReaderOptions 在 IronBarcode 中的作用是什么? IronBarcode 中的 BarcodeReaderOptions 允许您指定要读取的条形码类型,通过关注指定的格式来优化读取过程。 IronBarcode 可以讀取標準和擴展的 Code 39 條碼嗎? 是的,IronBarcode 可以讀取標準和擴展的 Code 39 條碼。對於擴展條碼,請確保UseCode39ExtendedMode屬性設為true。 IronBarcode 是否支持 Code 39 條碼中的特殊字符? 是的,IronBarcode 支援 Code 39 條碼中的特殊字符。標準版支援少數特殊字符,而擴充版則支援所有 ASCII 字元。 要解碼 Code 39 條碼中的完整 ASCII 集,需要哪些條件? 要在 Code 39 BarCode 中解碼完整的 ASCII 集,您必須使用擴充版本,並在 IronBarcode 中將 UseCode39ExtendedMode 屬性設定為 true。 IronBarcode 是否能夠使用圖像檔案進行條碼讀取? 是的,IronBarcode 可以從影像檔案讀取條碼。您可以將條碼圖片與 BarcodeReaderOptions 一起傳給 Read 方法來擷取資料。 Curtis Chau 立即與工程團隊聊天 技術作家 Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。 準備好開始了嗎? Nuget 下載 1,979,979 | Version: 2025.11 剛發表 免費下載 NuGet 下載總數:1,979,979 檢視授權