.NET software is designed to work with Unicode characters. Most barcodes are designed for ASCII. While the two happily co-exist for ASCII characters up to 127, problems arise with the “higher ASCII” characters 128-255. Graphic images and encrypted data needs to use data byte values greater than 127 and may include 0.
The dBarcode.NET components that support higher ASCII characters can convert the Unicode Caption string into a byte array to extract the 8-bit values required. This is done automatically when the ByteNumber property is set to a value greater than 0 and equal to the number of 8-bit bytes to be used as data.
The developer can take 8-bit data, place it in a byte array in ALTERNATE bytes – with the other bytes set to 0 – and then use the UnicodeEncoding GetString() method to return a Unicode string containing the data.
A simple example for encoding the ASCII values 0 - 255 is illustrated below:
Imports System.Text
Dim x As String
Dim
AE As New
UnicodeEncoding
Dim i, j, k As Integer
Dim ByteArray() As Byte = New Byte(2048)
{}
x =
""
j =
0
k =
0
For i = 0 To
255
ByteArray(k) =
i
ByteArray(k + 1) =
0
k = k +
2
Next i
x = AE.GetString(ByteArray)
Abcnet1.Caption = x
Abcnet1.ByteNumber = 256
More: