Code 128/ EAN-128

Code 128 and EAN-128 are modern very high density coding schemes that are somewhat more complex than most other schemes. They have three coding schemes each and permit the inclusion of special characters not present on the keyboard.  In general, because of the presence of non-printing characters, 128 type codes are best reproduced using the fonts that do NOT include text under the bars, such human readable text being added separately.

Spaces may be stripped from the text provided for input by setting the Extra1 property to true.

There are 105 characters in the character set, but each one may be used to represent more than one human readable character - see the table below. For example, the character with a Code 128 value of 77 represents a carriage return (CHR$(13)) in coding scheme A, the lower case letter m in scheme B, and the digit pair 77 in scheme C. This may be created in Basic using CHR$(77+32) = CHR$(109) [the coding scheme starts at ASCII 32].

Generally scheme B is used by default. For EAN-128 scheme C is used for any code that has numbers in the first four digits (as recommended by the ANA). The scheme must be specified by making the first character one of the start characters specified below. The stop character is always the same and is provided as ¬ (CHR$(172)) in the dLSoft barcode font.

In an attempt to simplifying the task of encoding characters the dLSoft 128 font provides the entire ASCII character set; obviously some of the 105 Code 128 characters are duplicated. ASCII values from 0 to 31 are available within the font as duplicates of the ASCII values 192 to 223. So setting CHR$(27) into the barcode font will produce the correct pattern, as will setting the character Ű. The character Ű has an ASCII value of 219 = 192 + 27.

Some of the control characters (values above 127) are not defined in some text fonts - so tend to show up as identical blocks. To make strings containing these characters easier to read before they become barcode symbols, the characters from CHR$ 128 to 137 are duplicated at 161 to 170. The latter are defined, as you can verify by holding down the ALT key and typing 0161 in Notepad.

The space character, ASCII 32, is reproduced at ASCII 159 and 160, and the ASCII 127 character is reproduced at ASCII 191.

The 128 coding standard allows the scheme to be changed within the symbol. Thus a symbol which starts with scheme C may be changed to scheme B part way through by using one of the special function codes (Code B). It is beyond the scope of this document to provide a tutorial in the use of 128 codes, and the user who needs more information should contact his national Article Numbering Association for details of the schemes and practices adopted locally.

The Code 128 character set is reproduced in the table below. Note that these are the codes that actually form the barcode symbol characters; they are NOT the characters used to insert your own contol codes when forming a barcode using the supporting libraries – See “Code 128 control codes” in the Supporting software section.

128 codes have a mandatory check digit that is calculated using a Modulo 103 of the weighted sum of the other characters in the code, where the weightings are determined by the character position (starting from the left). The result must have 32 added to it to enable the check digit character to be inserted as CHR(x).

The dFont program provided with the dLSoft Barcode fonts calculates check digits for Code 128 codes, and the source code is provided and may be adapted to the users needs - for example, for automating the calculation in a spreadsheet or database.

The dFont Helper application does not automatically handle subtype changes – you need to insert the subtype characters yourself. The dFont Developers Kit is available for developers who need to automate this process.

More:

EAN-128