The Code 128 barcode is a variable-length, alphanumeric, self-checking 1D barcode with an optional checksum for error detection. Similar to Code 39 Extended, Code 128 is able to encode the full ASCII character set. Code 128 also provides greater data density than the Code 93 symbology.
Example Barcode
The following example barcode encodes the information "Code 128"
as an Code 128 barcode:
Details
Code 128 was designed to encode all 128 ASCII characters. Although Code 128 was originally created as a 7 bit ASCII code, the 2007 update of the ISO-15417 Specification, Section 4.3.4.2 (d), describes a method for encoding of byte values from 128-255. Data in the range 128-255 is referred to as extended character set data and can be used to encode data outside the normal ASCII range.
EAN 128
EAN 128 is a variant on Code 128 that uses a double start character.
EAN 128 Example
The following example barcode encodes the information "EAN 128"
as an EAN 128 barcode:
Barcode Breakdown
A Code 128 can actually be divided into three subsets: A, B, and C. Each subset has a separate start code to indicate which subset is being used. In addition, each subset includes control characters to switch to another subset in the middle of a barcode.
- A – Digits, uppercase characters, standard ASCII symbols, and control codes.
- B – Digits, uppercase and lowercase characters, standard ASCII symbols, and control codes.
- C – Numeric only. Compresses two numeric digits into each character, providing excellent density. Barcode Xpress will add a leading "0" if there are an odd number of digits in the code.
Error Correction
Each Code 128 barcode includes a modulo 103 checksum. Additionally, each character has specific spacing that provides the basis for charcter-by-character consistency checking during scanning. Each character is 11 times the width of the most narrow bar, and consists of 3 bars and 3 spaces. The bars always use an even number of elements and the spaces use an odd number.
Managing Organization
The Code 128 is governed by ISO/IEC 15417:2007.1 The "GS1-128" variant is governed by GS1. 2
Platform-Specific Notes
When writing, the BarcodeValue property is interpreted as an ASCII string. Therefore, if your data contains extended character set data, you should use the BarcodeData property rather than the BarcodeValue property.
When the BarcodeType property is set to write a Code 128 barcode, Barcode Xpress will automatically switch between the three character sets (A, B, and C) to code the data in the shortest form.
Barcode Xpress will generate an error if you have characters in your barcode value that are not allowed.
When reading, the BarcodeValue property of the Result class is an ASCII string. Any character outside the printable ASCII range (decimal 31, for example) is represented as "?". To interpret the barcode data according to another character set, such as ISO 8859-1, use the BarcodeDataAsByte property instead of BarcodeValue.
Code 128 requires a quiet zone, which should be at least the width of 10 narrow bars. This means that if you set the MinimumBarWidth property to 3 pixels (narrow bar size), you should set the HorizontalWhiteSpace property to 30 pixels.
When writing, the BarcodeValue property is interpreted as an ASCII string. Therefore, if your data contains extended character set data, you should use the BarcodeData property rather than the BarcodeValue property.
When the BarcodeType property is set to write a Code 128 barcode, Barcode Xpress will automatically switch between the three character sets (A, B, and C) to code the data in the shortest form.
Barcode Xpress will generate an error if you have characters in your barcode value that are not allowed.
When reading, the BarcodeValue property of the Result class is an ASCII string. Any character outside the printable ASCII range (decimal 31, for example) is represented as "?". To interpret the barcode data according to another character set, such as ISO 8859-1, use the BarcodeDataAsByte property instead of BarcodeValue.
Code 128 requires a quiet zone, which should be at least the width of 10 narrow bars. This means that if you set the MinimumBarWidth property to 3 pixels (narrow bar size), you should set the HorizontalWhiteSpace property to 30 pixels.
When writing, the BarcodeValue property is interpreted as an ASCII string. Therefore, if your data contains extended character set data, you should use the BarcodeData property rather than the BarcodeValue property.
When the BarcodeType property is set to write a Code 128 barcode, Barcode Xpress will automatically switch between the three character sets (A, B, and C) to code the data in the shortest form.
Barcode Xpress will generate an error if you have characters in your barcode value that are not allowed.
When reading, the BarcodeValue property of the Result class is an ASCII string. Any character outside the printable ASCII range (decimal 31, for example) is represented as "?". To interpret the barcode data according to another character set, such as ISO 8859-1, use the BarcodeDataAsByte property instead of BarcodeValue.
Code 128 requires a quiet zone, which should be at least the width of 10 narrow bars. This means that if you set the MakeBarcodeBarSize property to 3 pixels (narrow bar size), you should set the MakeBarcodeBWidth property to 30 pixels.
Barcode Xpress will generate an error if you have characters in your barcode value that are not allowed.
When the BarcodeType property is set to write a Code 128 barcode, the barcode engine will automatically switch between the three character sets (A, B and C) to code the data in the shortest form.
The barcode engine will generate an error, if you have characters in your barcode value that are not allowed.
Code 128 requires a quiet zone, which should be at least the width of 10 narrow bars. This means that if you set the MinimumBarWidth property to 3 pixels (narrow bar size), you should set the HorizontalWhiteSpace property to 30 pixels.
The barcode engine will generate an error, if you have characters in your barcode value that are not allowed.
Similar Barcode Types
EAN 128 is also referred to as "GS1-128" or formerly "UCC 128".
Barcode Variants
EAN 128 is a variant of Code 128 with a double start character.
Related Barcodes
Code 128 barcodes were designed to encoding domain and data density in comparison to Code 39 symbology.
References
-
"Code 128 Bar Code Symbology Specification." ISO/IEC 15417:2007, ISO/IEC, Feb. 2008, www.iso.org/standard/43896.html.
-
"GS1 Standard Specifications." GS1, GS1 Organization, Jan. 2020, www.gs1.org/sites/default/files/docs/barcodes/GS1_General_Specifications.pdf.
For additional background and use-case information see our Code 128 barcode page and EAN 128 barcode page.
For more information, see the Barcode Xpress SDK product page or try our online demos.