Continuing our last post How to encode extended ASCII characters (bytes 128-255) ISO-8859-1 in USS Code 128 Barcode Symbology where we talked about the FNC1 and FNC4 function characters (sometimes it is also called or referred as Function Codes) on Code 128 barcodes, this post will be about Function Character 2 a.k.a. FNC2
The main mission of FNC2 is to allow encoding long messages or data (which in one only Code 128 barcode could not be practicable) into a set of shorter Code 128 barcodes in a way which in barcode terminology is known as “Message Append” or “Structured Appended Messages”
FNC2 works as follows:
FNC2 Encoding: The data to encode is split into n strings. The first n-1 of those strings is prefixed with FNC2 data character. The last n string is encoded as is.
NOTE: From the spec, FNC2 may occur anywhere in the data character but some barcode reader/scanner manufactures suggest the first data character for FNC2 position.
- FNC2 Decoding: The barcode reader/scanner decodes a Code 128 symbol. If the first data character is FNC2, then the decoded data is appended to a temporally storage buffer. The operation continues for all successive Code 128 barcodes with a FNC2 being the decoded data appended to the buffer. The sequence ends when a Code 128 symbol does not include a FNC2. In that last step, the reader/scanner decodes the Code 128 barcode, the data is appended to the buffer, the entire buffer is transmitted, and finally, the buffer is cleared.
NOTE: It is important to print the Code 128 barcodes in the correct sequence or provide to the user with some kind of guide about the decoding order. In Code 128 there’s no concept of “barcode index” when using FNC2, something that is common on 2D symbologies when encoding Structured Appended Messages.
You will need as many instances of BarcodeProfessional class as number of Code 128 barcodes you want to generate. Then to encode FNC2 you can use the CODE128_FNC2 constant and append it to the value to encode. For example, the following will encode and generate 3 barcodes:
BarcodeProfessional1.Symbology = Symbology.Code128; BarcodeProfessional1.Code = BarcodeProfessional.CODE128_FNC2 + "DATA123"; BarcodeProfessional2.Symbology = Symbology.Code128; BarcodeProfessional2.Code = BarcodeProfessional.CODE128_FNC2 + "DATA456"; BarcodeProfessional3.Symbology = Symbology.Code128; BarcodeProfessional3.Code = "DATA789";
BarcodeProfessional1.Symbology = Symbology.Code128 BarcodeProfessional1.Code = BarcodeProfessional.CODE128_FNC2 + "DATA123" BarcodeProfessional2.Symbology = Symbology.Code128 BarcodeProfessional2.Code = BarcodeProfessional.CODE128_FNC2 + "DATA456" BarcodeProfessional3.Symbology = Symbology.Code128 BarcodeProfessional3.Code = "DATA789"
After decoding, the reader/scanner should transmit DATA123DATA456DATA789
NOTE: Please verify your reader/scanner does support USS Code 128 FNC2