8.11. Code 128

Code 128 is a high-density alpha-numeric symbology. Since introduced in early 1980s, it has gained wide popularity in many industries. UCC/EAN derives its retail carton tracking standard UCC/EAN 128 based on Code 128 symbology.

Code 128 is a variable length, continuous symbology with multiple element widths. Every Code 128 symbol has a check character. Each character is encoded with three bars and spaces, in total 11 modules.

In the most recent standard ISO/IEC 15417, Code128 is extended to encode all 256 characters of a single-byte character set[1]. The default character set is ISO 8859-1 (Latin Alphabet No. 1).

Code 128 standard also defines four function codes for special purposes. FNC2 is used to tell barcode reader to store the data and transmit with next symbol; FNC4 is used as a latch code word to switch into extended ASCII mode. FNC3 is reserved for future use. FNC1 is used in UCC/EAN128 to act as UCC/EAN-128 identifier and field delimiter.

8.11.1. How Monterey Barcode Creator Implements Code128

Monterey Barcode Creator allows encoding all 256 characters as well as 4 special symbol characters: FNC1, FNC2, FNC3and FNC4.

Internally Code128 defines 3 character sets (A, B and C) to allow efficient encoding. Each character set contains 103 characters (including special symbol characters). A code128 symbol starts with one character set and latches to a different set with a latch codeword. Since these three character sets overlap, it is possible to get different barcodes with the same data encoded.

To allow space efficiency, during the encoding process, the Monterey Barcode Creator selects the proper character sets and inserts necessary shift characters to make the symbol generated as short as possible.

Code128 requires a checksum character to ensure the data integrity. The checksum character has no meaning to the end user. Monterey Barcode Creator does not transmit the checksum digit back to the human readable text.

Note

The Monterey Barcode Creator always tries to create the shortest barcode. For example, if Monterey Barcode Creator sees that some portion of the data is best fit encoded with Code128 C,it automatically select character set C. The end user does not have the control on how the data is encoded.

8.11.2. Tilde Codes

Under some circumstances, it is necessary to represent some characters with an ASCII-only format. This kind of representation format is called escape sequence. For example, the four special Code128 symbol characters, FNC1~FNC4, do not have corresponding ASCII values. Consequently the only way to enter them into the Message property is through their escaped forms. Some applications and programming environments may only accept printable ASCII characters, and control characters must be escaped.

Tilde code sequence is the only escape method supported in Monterey Barcode Creator version 3.2 and above. The special character input method (escaping a character using a back-slash character followed by 3-digit character value) present in previous versions is now deprecated.

The tilde code consequences used in Code128 are listed as below:

~dnnn

When nnn corresponds to a numeric value between 0 and 255, the tilde code sequence represents a character with value equal to nnn. For example, ~d032 represents a space character.

~~

Represents a tilde (~) character.

~1

Represents a FNC1 character. The tilde escape sequence can appear anywhere in the input.

~2

Represents a FNC2 character.

~3

Represents a FNC3 character.

~4

Represents a FNC4 character. FNC4 is used to encode extended ASCII characters. You do not need to enter the FNC4 in most circumstances. Just pass the extended characters you'd like to encode.

~X

Represents a character value from 0 to 26. Replace the X like in the following example ~@ means character ascii 0, ~A means character 1, ~B means character 2, ~C means character 3 and so on.

Note

Due to the fact that each symbology encodes different character set, the tilde code sequence varies from symbology to symbology. Refer to the tilde codes section of each symbology to understand how to escape the character.



[1] Published in year 2000, this standard is relative new to the industry. Not all scanners in the market support this feature.