Code 128 Barcodes
Code 128 is a high-density 1D barcode symbology. This barcode set makes use of the entire 128 ASCII characters which include letter, number and symbols.
As with all barcodes, there are indicators to identify where the barcode starts and stops. These are marked in yellow below. Code 128 also has a check character which has been marked in green. The remainder of the barcode is the data being encoded. The text below the barcode is optional and is for human consumption in the event the barcode can't be scanned or if people also need to know what the code means.
Each character in the barcode symbol is composed of three bars and three spaces. Each bar or space must range from 1-4 units and the sum of all the width of all bars must work out to an even number. The stop marker is special because it adds an extra bar of 2 units at the very end (4 bars and 3 spaces). There are three different start markers to to identify which code set is being used. To represent all 128 characters, the code sets can be within a single barcode as needed by using control characters 98-101 (depending on the code set).
The check character is calculated by summing the value of each character and multiplying it by its position. The start character is also part of the sum but is added without weight (multiply by 1 just like the first encoded data character) then when you have the sum take the modulo 103 remainder. This gets a little more complex when mixing modes within a single barcode.