VintaSoft Barcode .NET SDK v10.0
EciCharacterEncoder Class
Members  Example 




Vintasoft.WpfBarcode.BarcodeInfo Namespace : EciCharacterEncoder Class
Provides methods for encoding of Extended Channel Interpretation (ECI) characters.
Object Model
EciCharacterEncoder Class
Syntax
'Declaration
 
Public Class EciCharacterEncoder 
'Usage
 
Dim instance As EciCharacterEncoder
public class EciCharacterEncoder 
public __gc class EciCharacterEncoder 
public ref class EciCharacterEncoder 
Remarks
ECI character in the barcode value specifies the character encoding of text after the ECI character and until the end of barcode value or next ECI character.
Several ECI characters can be used for storing text with different character encodings in the single barcode value.

Important: Not all barcode readers support ECI characters! Use ECI characters only if your barcode reader supports ECI characters. Use text in UTF8 encoding and encode text as bytes (System.Text.Encoding.GetBytes(System.String)) if you are not sure about support of ECI characters by your barcode reader.

ECI characters are available only for Aztec, DataMatrix, QR, Han Xin Code, PDF417 or Micro PDF417 barcodes.
Example
This example shows how to encode and decode text with different encodingss:
Imports System.Windows.Media.Imaging   
Imports System.Text   
   
Imports Vintasoft.WpfBarcode   
Imports Vintasoft.WpfBarcode.BarcodeInfo   
   
''' <summary>   
''' Class that shows how to create an image with barcode Aztec, DataMatrix, QR, Han Xin Code,   
''' PDF417 or Micro PDF417, which stores text in different encodings.   
''' Barcode value is encoded using the EciCharacterEncoder class.   
''' </summary>   
Class EciCharacterEncoderExample   
	''' <summary>   
	''' Runs the test.   
	''' </summary>   
	Public Shared Sub Run()   
		' ECI characters are available only for Aztec, DataMatrix, QR, PDF417 or Micro PDF417 barcodes   
		Dim barcodeType__1 As BarcodeType = BarcodeType.DataMatrix   
   
		' create the encoder of Extended Channel Interpretation (ECI) characters   
		Dim eciEncoder As New EciCharacterEncoder(barcodeType__1)   
   
		' create the ECI encoding for encoding text in codepage 28592   
		Dim cp28592EciEncoding As EciCharacterEncoding = EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28592))   
		' append text in codepage 28592 to ECI encoder   
		eciEncoder.AppendText(cp28592EciEncoding, "ążśźęćń󳥯ŚŹĘĆŃÓŁ")   
   
		' create the ECI encoding for encoding text in codepage 28595   
		Dim cp28595EciEncoding As EciCharacterEncoding = EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28595))   
		' append text in codepage 28595 to ECI encoder   
		eciEncoder.AppendText(cp28595EciEncoding, "АБВГДЕЖЗИЙКЛМНОП")   
   
		' create the ECI encoding for encoding text in codepage 950   
		Dim cp950EciEncoding As EciCharacterEncoding = EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(950))   
		' append text in codepage 950 to ECI encoder   
		eciEncoder.AppendText(cp950EciEncoding, "日月火水木金土")   
   
		' create the ECI encoding for encoding text in codepage 28591   
		Dim cp28591EciEncoding As EciCharacterEncoding = EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28591))   
		' append text in codepage 28591 to ECI encoder   
		eciEncoder.AppendText(cp28591EciEncoding, "test!")   
   
   
		' create the barcode writer   
		Dim writer As New BarcodeWriter()   
   
		' specify that writer must generate barcode of specified type   
		writer.Settings.Barcode = barcodeType__1   
   
		' set the barcode value as value encoded by ECI encoder   
		writer.Settings.ValueItems = eciEncoder.ToValueItems()   
   
		' create image with barcode   
		Dim barcodeImage As BitmapSource = writer.GetBarcodeAsBitmapSource()   
   
		' create the barcode reader   
		Using reader As New BarcodeReader()   
			' specify that reader must search for barcodes of specified type   
			reader.Settings.ScanBarcodeTypes = barcodeType__1   
   
			' read barcode from image   
			Dim decodeItems As ValueItemBase() = reader.ReadBarcodes(barcodeImage)(0).ValueItems   
   
			' decode the barcode value   
			Dim decodedString As String = EciCharacterDecoder.Decode(decodeItems)   
   
			' if decoded value does not match source value   
			If decodedString <> "ążśźęćń󳥯ŚŹĘĆŃÓŁАБВГДЕЖЗИЙКЛМНОП日月火水木金土test!" Then   
				' throw exception   
				Throw New ApplicationException()   
			End If   
		End Using   
   
		Console.WriteLine("OK")   
	End Sub   
End Class
using System;
using System.Windows.Media.Imaging;
using System.Text;
            
using Vintasoft.WpfBarcode;
using Vintasoft.WpfBarcode.BarcodeInfo;
            
/// <summary>
/// Class that shows how to create an image with barcode Aztec, DataMatrix, QR, Han Xin Code,
/// PDF417 or Micro PDF417, which stores text in different encodings.
/// Barcode value is encoded using the EciCharacterEncoder class.
/// </summary>
class EciCharacterEncoderExample
{
    /// <summary>
    /// Runs the test.
    /// </summary>
    public static void Run()
    {
        // ECI characters are available only for Aztec, DataMatrix, QR, PDF417 or Micro PDF417 barcodes
        BarcodeType barcodeType = BarcodeType.DataMatrix;
            
        // create the encoder of Extended Channel Interpretation (ECI) characters
        EciCharacterEncoder eciEncoder = new EciCharacterEncoder(barcodeType);
            
        // create the ECI encoding for encoding text in codepage 28592
        EciCharacterEncoding cp28592EciEncoding =
            EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28592));
        // append text in codepage 28592 to ECI encoder
        eciEncoder.AppendText(cp28592EciEncoding, "ążśźęćń󳥯ŚŹĘĆŃÓŁ");
            
        // create the ECI encoding for encoding text in codepage 28595
        EciCharacterEncoding cp28595EciEncoding =
            EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28595));
        // append text in codepage 28595 to ECI encoder
        eciEncoder.AppendText(cp28595EciEncoding, "АБВГДЕЖЗИЙКЛМНОП");
            
        // create the ECI encoding for encoding text in codepage 950
        EciCharacterEncoding cp950EciEncoding =
            EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(950));
        // append text in codepage 950 to ECI encoder
        eciEncoder.AppendText(cp950EciEncoding, "日月火水木金土");
            
        // create the ECI encoding for encoding text in codepage 28591
        EciCharacterEncoding cp28591EciEncoding =
            EciCharacterEncoding.GetEciCharacterEncodingForEncoding(Encoding.GetEncoding(28591));
        // append text in codepage 28591 to ECI encoder
        eciEncoder.AppendText(cp28591EciEncoding, "test!");
            
            
        // create the barcode writer
        BarcodeWriter writer = new BarcodeWriter();
            
        // specify that writer must generate barcode of specified type
        writer.Settings.Barcode = barcodeType;
            
        // set the barcode value as value encoded by ECI encoder
        writer.Settings.ValueItems = eciEncoder.ToValueItems();
            
        // create image with barcode
        BitmapSource barcodeImage = writer.GetBarcodeAsBitmapSource();
            
        // create the barcode reader
        using (BarcodeReader reader = new BarcodeReader())
        {
            // specify that reader must search for barcodes of specified type
            reader.Settings.ScanBarcodeTypes = barcodeType;
            
            // read barcode from image
            ValueItemBase[] decodeItems = reader.ReadBarcodes(barcodeImage)[0].ValueItems;
            
            // decode the barcode value
            string decodedString = EciCharacterDecoder.Decode(decodeItems);
            
            // if decoded value does not match source value
            if (decodedString != "ążśźęćń󳥯ŚŹĘĆŃÓŁАБВГДЕЖЗИЙКЛМНОП日月火水木金土test!")
                // throw exception
                throw new ApplicationException();
        }
            
        Console.WriteLine("OK");
    }
}
Inheritance Hierarchy

System.Object
   Vintasoft.WpfBarcode.BarcodeInfo.EciCharacterEncoder

Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

EciCharacterEncoder Members
Vintasoft.WpfBarcode.BarcodeInfo Namespace
EciCharacterDecoder Class
EciCharacterValueItem Class