How to scan, read barcode image with Unicode text in C#?

How to scan, read, decode Unicode text from barcode images for ASP.NET Core web app and Windows application?

Using Free C# Souce Code to read, decode barcode images with Unicode text for ASP.NET Web Application & IIS Projects



The following guide will help you how to read Unicode text from barcode images using C#. Parse the extracted barcode data in byte array, and convert the byte array into unicode text in string object.








About Unicode text in barcode

Top
Most barcode symbologies do not support encode Unicode text directly into barcode symbols. However 2d barcodes (Such as QR Code, Data Matrix, and PDF-417) usually support encoding byte array data message. C# developers could convert Unicode text into byte array, and encode the byte array into barcode symbols.

During decoding barcode image using barcode reader software or device, C# developer could read byte array data from 2d barcode symbols, and decode the byte array into string with Unicode text.




How to scan, read Unicode text from 2D barcodes using C#?

Top
In the following C# source code, we will show you how to read a QR Code barcode image with Unicode text (English, Chinese, and Japanese characters inside).

We will try to read and recognize the Unicode text content from the following QR Code image, which is generated by OnBarcode C# barcode generator library. You can view the C# demo code at How to generate QR Code with Unicode text using C#



The above QR Code encodes the following text message with English, Chinese, and Japanese characters inside





  • Get all QR Code data from a single image file using C# method BarcodeScanner.ScanInDetails()

  • For each QR Code data, get the byte array of the data message using method BarcodeDetail.GetDataBytes()

  • Get the Unicode text using UTF8 decoding in method System.Text.Encoding.UTF8.GetString()


            string inputFilePath = "W://Projects//Test-Input//csharp-qrcode-unicode-sample.png";

            // scan all QR Code symbols in the image file
            BarcodeDetail[] datas = BarcodeScanner.ScanInDetails(inputFilePath, BarcodeType.QRCode);
            for (int j = 0; j < datas.Length; j++)
            {
                byte[] dataInBytes = datas[j].GetDataBytes();

                string textMsgDecoded = System.Text.Encoding.UTF8.GetString(dataInBytes);

                Console.WriteLine("message: " + textMsgDecoded);
            }


When you run the program, you will find the scanned QR Code data below.
















OnBarcode is a market-leading provider of barcode imaging generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides comprehensive tutorials and how-tos for various linear, 2d barcode information, such as C# in ASP.NET, C# .NET, C# Barcode Encoding, C# Barcode Image, VB.NET in ASP.NET, VB.NET Winforms, VB.NET Barcode Encoding. OnBarcode barcode products are supported by RasterEdge ASP.NET Document Viewer, which supports ASP.NET PDF Viewer, ASP.NET MVC Document Viewer, ASP.NET PDF Editor, MVC PDF Viewer. And provide high quality C# Convert PDF to Tiff, C# Convert PDF to Word, C# Convert PDF to HTML, C# Convert PDF to Jpeg images, and their easy and simple documents, like C# PDF SDK, C# extract text from PDF, C# Compress PDF, Print PDF in C# and C# extract image from PDF.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.