How to encode Unicode in PDF417-DataMatrix-QRCode-AztecCode with Barcode Professional in C# or VB.NET
Product Barcode Professional SDK for .NET
Most current 2D barcodes like Data Matrix, QR Code, Aztec Code, PDF417, etc; were not designed to encode Unicode two-byte characters but single-byte strings only. In general, the default character set for 2D barcodes is ISO-8859-1 Latin 1 although it is possible to use other single-byte character sets by using ECI (Extended Channel Interpretation) feature.
So if you pretend to encode Unicode strings in languages like Arabic, Chinese, Hebrew, Hindi, Japanese, Korean, etc.; you will have to use some conversion technique BEFORE generating the 2D barcode AND AFTER the scanner decodes it in your application.
Neodynamic Barcode Professional SDK 3.0 for .NET (or greater)
Microsoft .NET Framework 2.0 (or greater)
Microsoft Visual Studio 2010 or Visual Basic 2010 Express or Visual C# 2010 Express
There're plenty of "conversion methods" to be used but the only one we found reliable was using the Base64 encoding algorithm. The whole process is very straightforward and could be illustrated as follows.
The Barcode Encoding process
To encode a Unicode string into for example a 2D DataMatrix barcode, you must first convert the two-byte Unicode characters to a Base64 string before passing it to Barcode Professional. The conversion from Unicode to Base64 is very simple by using System.Text.Encoding.Unicode.GetBytes first and then System.Convert.ToBase64String
The Barcode Decoding process
Based on the fact that you encoded a Base64 string representing the two-byte Unicode characters, the decoding process requires you handle in your application the decoded string sent by the barcode scanner which should be the Base64 string in the 2D Barcode. After you get that Base64 string you can easily convert it back to a Unicode string by using System.Convert.FromBase64String first and then System.Text.Encoding.Unicode.GetString
A sample .NET application about Unicode encoding in 2D Barcodes
We have written a simple .NET Windows Forms application so you can see how to code both process i.e. encoding and decoding parts. We used our Barcode Professional SDK for .NET dll for generating the 2D barcodes encoding the Unicode/Base64 string. From this app you can generate and print the 2D for the entered Unicode string. Then changing to the "Decoding" tab you can use your preferred scanner (you will need a barcode scanner capable of decoding 2D symbologies like Data Matrix, QR Code, Aztec Code or PDF417) and test the printed barcode.
Here is a couple of screenshots of the application encoding the Chinese Unicode version of "Hello World" encoded in a 2D Data Matrix barcode. Notice that you can encode the same Unicode string in other standards like PDF417, Aztec Code and QR Code.
Sample Files Download
Here are the VB.NET and C# versions of this sample. Please download the zip file and extract it.
Remember to download and install Barcode Professional SDK for .NET in order to reproduce this sample demo.