Login | Create Account

Cognex Mobile Barcode Scanner SDK
Code 128

What is Code 128?

Code 128, or Code128, was introduced in 1981 as a much more efficient alternative to older barcodes like Code 11, Code 39, and Codabar. Unlike its predecessors, which are limited to a subset of alphanumeric and symbol characters, Code 128 can be used to represent the full ASCII character set (characters 0 through 127).

Code 128 is often referred to as GS1-128 (formerly UCC/EAN-128), which is a widely supported application standard in the shipping and packaging industries.

Code 128 is a linear, or one-dimensional (1D) barcode. This means the barcode is composed of a single set of varying-width vertical lines and spaces. The data in the barcode is represented linearly by these black/white (bar/space) patterns. Below is a simple example.

 

 

Each symbol in a Code 128 barcode has 6 elements: 3 bars (black) and 3 spaces (white), with the exception of the stop symbol, which has 7 elements (4 bars and 3 spaces). It uses 108 different symbols: 103 data symbols, 3 start symbols, and 2 stop symbols. It defines three different character sets or character modes (128A, 128B, and 128C). Each data symbol represents a different character depending on which character set is active; the initial character mode is set by the start character (which is why there are 3 different ones). Special symbols are used within the data message to change to a different character set if needed. These switches are called shifts (switch to a different character set for the next symbol only) and latches (shift to a different character set for all subsequent symbols).

The symbology is further characterized as a continuous barcode, meaning that each character is adjacent to the next with no inter-character gap element. Here is our example again, diagramed for clarity:

 

 

In the example above, the symbol is started in character set B (128B), as this character set includes both upper and lower case letters (character sets 128A and 128C do not).

Code 128 also includes a mandatory checksum (appearing after the data message, before the stop symbol). A modulo 103 computation is used.

Why use Code 128?

Code 128 is widely supported, with most commercial barcode scanners being capable of reading it. Its high density and ASCII 127 support make it ideal for a wide variety of uses. Its symbols are more complex to generate than less capable symbologies like Code 39 (since they support multiple character sets and require a checksum), so encoding software is often used in conjunction with specialized fonts.

Who uses Code 128?

Code 128 is used extensively in many industries:

  • Shipping and Packaging – both FedEx and UPS use it on their shipping labels, as well as other carriers. Code 128 is part of the standard MH10.8 barcode label specification, and is the barcode used in the GS1 global standard for commercial data exchange, GS1-128;
  • USPS – the United States Postal Service now uses Code 128 barcodes as part of its Intelligent Mail package barcodes (IMpb) for package tracking. As of January 1, 2015, this barcode is now required on all commercial packages shipped via USPS and offers discounts and free insurance on Priority Mail items that include the barcode;
  • Human medical products - ISBT 128 (International Standard for Blood and Transplant) defines the use of Code 128 for the identification, labeling, and information transfer of medical products like blood, tissue, and organs;
  • Healthcare – It is one of the supported barcodes in the FDA’s broad medical device labeling standard, UDI (Unique Device Identification), and the Health Industry Bar Code (HIBC);
  • Military – the US Department of Defense uses Code 128 for asset labeling and tracking across all branches of the military (IUID: Item Unique Identification, part of Military Standard 130).

How do we help developers using Code 128?

The Cognex Mobile Barcode Scanner SDK supports Code 128 detection, enabling developers to gather relevant workflow and application data into their barcode scanning apps. You can download the SDK for free by registering on the Cognex Mobile Barcode Developer Network. In addition, the Barcode Scanner SDK supports a broad range of symbologies to meet your growing development needs.

Get Started