IronBarcode 操作指南 讀取 Code 39 BarCode Read Code 39 BarCode in C# Quickly and Easily 簡單快速地讀取Code 39 BarCode。 Curtis Chau 更新:2026年1月10日 下載 IronBarcode NuGet 下載 DLL 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English IronBarcode 通過使用 BarcodeEncoding.Code39 指定的 BarcodeReaderOptions 類,並在需要時啟用 UseCode39ExtendedMode 以獲得完整的 ASCII 字元支援,簡化了在 C# 中讀取標準和擴展 Code 39 條碼的過程。 Code 39 是一種通用的條碼格式,廣泛用於庫存、物流和工業應用中。 Code 39 BarCode 的長度可以變化,因此可以靈活運用於不同的使用情況。 原始的標準 Code 39 編碼包括大寫字母 (A-Z)、數字 (0-9) 和幾個特殊字符 (空格、-、$、+、% 和 .)。 這對於基本的 ID 非常有效,但現代的應用程式通常需要對所有 128 個 ASCII 字元進行編碼。 Code 39 Extended 規格可滿足此需求。 本指南展示了如何使用 IronBarcode 讀取標準和擴展的 Code 39 變體。 無論您是建立庫存管理系統、追蹤貨物運送或處理工業條碼,IronBarcode 都能提供可靠的 Code 39 讀取功能。 如需條碼讀取功能的完整概述,請查看我們的 全面條碼快速入門指南。 as-heading:2(Quickstart: Read Code 39 Barcodes in C#) 使用 IronBarcode 的BarcodeReader ,只需一行程式碼即可從影像中解碼 Code 39 條碼。 立即開始-指定編碼類型,傳入影像,然後讀取結果。 立即開始使用 NuGet 建立 PDF 檔案: 使用 NuGet 套件管理器安裝 IronBarcode PM > Install-Package BarCode 複製並運行這段程式碼。 IronBarCode.BarcodeReader.Read("code39.png", new IronBarCode.BarcodeReaderOptions { ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.Code39 }).First().ToString(); 部署到您的生產環境進行測試 立即開始在您的專案中使用 IronBarcode,免費試用! 免費試用30天 ## 如何在 C# 中讀取 Code 39 條碼 下載 IronBarcode C# 函式庫以讀取 Code39 條碼。 初始化一個新的BarcodeReaderOptions 在選項中指定 BarcodeEncoding.Code39 使用 Read 讀取 Code 39 條碼 驗證結果並列印到控制台 如何讀取標準 Code 39 BarCode? 使用 IronBarcode 讀取 Code 39 條碼非常簡單直接。 首先,初始化一個新的 BarcodeReaderOptions 並指定條碼類型為 BarcodeEncoding.Code39 。 這可以透過明確告訴讀取器應該尋找何種 BarCode 格式來進行最佳化。 接下來,使用 Read 方法讀取條碼,並傳入條碼影像和選項作為參數。 然後遍歷結果集合,並將每個 BarCode 的字串值列印到控制台。 如需進階設定,請參閱我們關於 BarCode 閱讀器設定的詳細指南。 標準 Code 39 BarCode 是什麼樣子? 此影像包含標準 Code 39 條碼。 請注意條碼如何在下方以 BarCode 和人類可讀文字的方式顯示其編碼值。 這種雙重表示法是工業和物流應用中 Code 39 BarCode 的典型表現。 閱讀標準 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()); } Imports IronBarCode Imports System Dim options As New BarcodeReaderOptions() With { .ExpectBarcodeTypes = BarcodeEncoding.Code39 } ' Read barcode(s) from the image file using the specified options Dim results = BarcodeReader.Read("code39.png", options) ' Loop through each BarcodeResult found in the image For Each result In results ' Print the decoded string value of the standard Code 39 barcode Console.WriteLine(result.ToString()) Next $vbLabelText $csharpLabel 指定預期的 BarCode 類型可大幅提升讀取效能。 IronBarcode 不會浪費時間去尋找其他條碼格式,這對批量處理大型影像集尤其有利。 透過我們的讀取速度選項指南瞭解更多關於最佳化條碼讀取效能的資訊。 我應該期待什麼樣的輸出? 控制台輸出顯示從我們的 Code 39 BarCode 成功解碼的值 "ABC-1234"。 退出代碼 0 確認執行成功且無錯誤。 在生產應用程式中,針對可能無法辨識 BarCode 的情況實施適當的錯誤處理。 如果您遇到問題,請查看我們的 無法辨識 BarCode 的疑難排解指南。 如何讀取擴展的 Code 39 BarCode? 讀取延伸 Code 39 BarCode 的過程與標準 Code 39 相似。關鍵差異在於設定 UseCode39ExtendedMode 屬性為 true。 此設定指示 IronBarcode 解譯特殊字符對 (例如 +T、%O),並將其解碼為完整的 ASCII 對應字元 (例如 t、!)。 Extended Code 39 使用兩個字元序列來表示標準字元集以外的字元。 這使得 BarCode 稍微變長,但可以對小寫字母、額外的標點符號和控制字元進行編碼。 何時應該使用延伸的 Code 39? 當您的應用程式需要編碼時,Extended Code 39 是理想的選擇: 混合大小寫文字(大寫和小寫字母) 特殊字符如 @、#、&、!、? 資料傳輸的控制字元 支援完整的 ASCII 字元集 常見的應用程式包括醫療保健系統、文件追蹤以及需要豐富資料編碼的進階庫存管理。 What Does an Extended Code 39 BarCode Look Like? 此影像包含擴充的 Code 39 條碼。 值Test-Data!包含小寫字元和感嘆號,這些字元僅在完整的 ASCII 字元集中可用,並且需要擴展模式。 延伸 Code 39 需要哪些程式碼? :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()); } Imports IronBarCode Imports System Dim options As New BarcodeReaderOptions() With { .UseCode39ExtendedMode = True, .ExpectBarcodeTypes = BarcodeEncoding.Code39 } ' Read barcode(s) from the extended code 39 image Dim results = BarcodeReader.Read("code39extended.png", options) ' Loop through each BarcodeResult found in the image For Each result In results ' Print the fully decoded ASCII string (e.g., "Test-Data!") Console.WriteLine(result.ToString()) Next $vbLabelText $csharpLabel 我應該從延伸模式期待哪些輸出? [{t:( 控制台輸出可能無法正確顯示所有 ASCII 字元。 在這種情況下,請將輸出重定向到 .txt 檔案以驗證提取結果。 進階的 Code 39 讀取技巧 處理多個 BarCode IronBarcode 可在單一影像中自動偵測並讀取多個 Code 39 條碼。 Read 方法會返回一個結果集合,讓您可以單獨處理每個條碼。 對於處理成張的 BarCode 或複雜文件的應用程式,請參閱我們的 讀取多重條碼指南。 處理品質不佳的圖片 Code 39 BarCode 有時候會在不太理想的情況下出現 - 打印褪色、角度歪斜或低解析度掃描。 IronBarcode 包括功能強大的 圖像校正篩選器,可顯著提高閱讀準確性: BarcodeReaderOptions options = new BarcodeReaderOptions() { ExpectBarcodeTypes = BarcodeEncoding.Code39, UseCode39ExtendedMode = true, // Apply image correction filters ImageFilters = new ImageFilterCollection() { new SharpenFilter(), new ContrastFilter(), new BrightnessFilter() } }; BarcodeReaderOptions options = new BarcodeReaderOptions() { ExpectBarcodeTypes = BarcodeEncoding.Code39, UseCode39ExtendedMode = true, // Apply image correction filters ImageFilters = new ImageFilterCollection() { new SharpenFilter(), new ContrastFilter(), new BrightnessFilter() } }; Dim options As New BarcodeReaderOptions() With { .ExpectBarcodeTypes = BarcodeEncoding.Code39, .UseCode39ExtendedMode = True, .ImageFilters = New ImageFilterCollection() From { New SharpenFilter(), New ContrastFilter(), New BrightnessFilter() } } $vbLabelText $csharpLabel 效能最佳化 對於大量的 BarCode 讀取應用程式,請考慮這些最佳化策略: 1.指定精確的 BarCode 類型 - 始終設定 ExpectBarcodeTypes 以避免不必要的掃描 2.使用適當的閱讀速度 - 根據您的需求平衡速度與精確度 3. 並行處理影像 - 利用多執行緒進行批次處理 4.預先處理影像 - 僅在必要時套用修正以維持效能 摘要 IronBarcode 簡化了 C# 中的 Code 39 條碼讀取,無論是使用標準格式還是擴展格式。 關鍵步驟如下 有了這些基本知識,您就可以將 Code 39 條碼讀取整合到您的 .NET 應用程式中。 如需完整的 API 文件和其他 BarCode 格式,請造訪我們的 全面的 API 參考資料。 如需特定於 Code 39 的實作範例,請參閱我們的 專用 Code 39 教學。 常見問題解答 什麼是 Code 39 及其常見用途? Code 39 是一種通用的條碼格式,廣泛用於庫存、物流和工業應用中。它的長度可以變化,因此可以靈活地應用於不同的使用情況。標準 Code 39 可編碼大寫字母 (A-Z)、數字 (0-9) 和幾個特殊字符,而 Code 39 Extended 則可編碼所有 128 ASCII 字符。IronBarcode 提供可靠的功能,可讀取標準和擴展的 Code 39 變體。 如何在 C# 中讀取標準 Code 39 BarCode? 要使用 IronBarcode 讀取 Code 39 條碼,首先初始化一個新的 BarcodeReaderOptions 並指定條碼類型為 BarcodeEncoding.Code39。然後使用讀取方法,傳入條碼影像和選項作為參數。最後,遍歷結果集合以存取每個條碼的字串值。 標準 Code 39 可以編碼哪些字元? 標準 Code 39 可編碼大寫字母 (A-Z)、數字 (0-9) 及數個特殊字符,包括空格、連字符 (-)、美元符號 ($)、Plus 符號 (+)、百分比 (%) 及句點 (.)。若要編碼全部 128 個 ASCII 字元,您需要使用 Code 39 Extended 模式,IronBarcode 透過 UseCode39ExtendedMode 選項支援此模式。 標準 Code 39 與擴充 Code 39 有何差異? 標準 Code 39 僅限於大寫字母、數字及少數特殊字符,對於基本 ID 非常有效。Code 39 Extended 能滿足現代應用程式對所有 128 ASCII 字元編碼的需求。IronBarcode通過在BarcodeReaderOptions類別中啟用UseCode39ExtendedMode來簡化對這兩種變體的讀取,以獲得完整的ASCII字符支持。 Code 39 BarCode 可以包含人可讀的文字嗎? 是的,Code 39 條碼通常會在條碼下方以條碼和人類可讀文字的方式顯示其編碼值。這種雙重表示在工業和物流應用中很常見,使操作員更容易驗證條碼內容。無論是否存在人可讀的文本,IronBarcode 都可以讀取條碼數據。 Curtis Chau 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 準備好開始了嗎? Nuget 下載 2,070,733 | 版本: 2026.2 剛剛發布 免費 NuGet 下載 總下載量:2,070,733 查看許可證