DLSoft Application Note 0709a Creating 2D barcodes with Unicode data using dBarcode.NET components Apples to dBarcode.NET - 2D Universal dBarcode.NET - Aztec dBarcode.NET - Datamatrix dBarcode.NET - PDF417 dBarcode.NET - QR Code If you are using only characters with ASCII values in the range 0 - 255 then this will not effect you! Most 2D barcode types encode alphanumeric characters as single byte ASCII values, which is fine for US/English, but has limitations for encoding arabic or chinese. When US/English data characters are supplied to one of the dBarcode.NET components for encoding in an alphanumeric mode the single byte characters are extracted from the data and encoded. So, for example, the characters "ABC" are encoded using the hexadecimal byte values: 41 42 43 Some 2D barcodes types (Aztec, Datamatrix, PDF417 and QR Code) can encode data containing any byte values 0 - 255, so it is possible to encode non-ASCII languages as Unicode byte pairs. For example, the first three kanji characters could be encoded as 41 30 42 30 43 30 However, if a string containing US/English and non-US/ENglish data is to be encoded then a decision has to be made; either everything is encoded using Unicode byte pairs, for example, combining the string from above (three knaji characters followed by "ABC") 41 30 42 30 43 30 41 00 42 00 43 00 or the non-ASCII characters are encoded as byte pairs and the ASCII characters as single bytes, ie. 41 30 42 30 43 30 41 42 43 The first method has the advantage that decoding is straighforward - interpret everything as Unicode - but the disadvantage that the barcode symbol is larger than it needs to be. The second method has the advantage of a minimum size symbol, but the disadvantage that the decoding software needs to know when the switch from Unicode to ASCII takes place. The dBarcode.NET components have a boolean Flag property. When the Flag is true the Caption property is treated as a Unicode string and all characters are encoded as byte pairs. So the characters from above encode as: 41 30 42 30 43 30 41 00 42 00 43 00 When the Flag property is false AND the ByteNumber property has NOT been specified (ie. its 0) then characters with values greater than 255 are encoded as byte pairs, while characters with values less than 256 are encoded as single bytes. So the characters from aboce encode as: 41 30 42 30 43 30 41 42 43 [Note that if Flag is false AND a non-zero ByteNumber value is specified, then the Caption is interpreted as a Unicode string made from a byte stream with alternate bytes of zero. So to encode the byte vales 00 01 02 03 first convert the bytes to a byte array with alternate values of 00, ie. 00 00 01 00 02 00 03 00 then set the component's Caption property to the corresponding Unicode string, eg. Dim ByteArray() as Byte = New Byte(2048) {} Dim AE as New UnicodeEncoding ....... put the byte in ByteArray ........ Abcnet1.Caption=AE.GetString(ByteArray) Abcnet1.ByteNumber=8 (total number of bytes - including the 00s) ...... This technique is useful when encoding pictures or other data streams that may have any byte values.] dLSoft September 2007