Barcode Code 128 is a high-density linear barcode symbology used extensively in various applications due to its compact size and versatility. |
It encodes all 128 ASCII characters and includes three subsets: A, B, and C. Each subset has a specific character set and application, with subset B being the most common for general alphanumeric data. |

|
Overview of Code 128 B |
1. Character Set Code 128 B encodes: Uppercase and lowercase letters (A-Z, a-z) Numeric digits (0-9) Special characters and symbols (e.g., space, !, ', #, $, %, &, ', (, ), *, +, ,, -, ., /) Control characters from ASCII 0 to 31 (though these are less commonly used in subset B) |
2. Structure and Encoding A Code 128 barcode consists of: Start character Data characters Check character Stop character Start Character For subset B, the barcode begins with the start character Start B. Data Characters Each data character is encoded using 11 modules (bars and spaces) of varying widths. Each character is represented by a unique combination of 3 bars and 3 spaces. Check Character A check character is calculated based on the value of each character in the barcode, providing an additional layer of error detection. Stop Character The barcode concludes with a stop character, which signals the end of the barcode. |

|
Detailed Encoding Process |
1. Start Character Start B: 104 (in the character set table) |
2. Data Encoding Each character in the data string is mapped to a corresponding value in the Code 128 character set table. For example: 'A' -> 33 'B' -> 34 'C' -> 35 '0' -> 16 '1' -> 17 ' ' (space) -> 0 |
3. Checksum Calculation The checksum is calculated using the following formula: Checksum=(Start Value)+∑(Character Value×Position Index)mod??103\text{Checksum} = (\text{Start Value}) + \sum (\text{Character Value} \times \text{Position Index}) \mod 103Checksum=(Start Value)+∑(Character Value×Position Index)mod103 For example, if encoding 'HELLO': Start B: 104 H (Position 1): 40 E (Position 2): 37 L (Position 3): 44 L (Position 4): 44 O (Position 5): 47 The calculation: 104+(40×1)+(37×2)+(44×3)+(44×4)+(47×5)=104+40+74+132+176+235=761104 + (40 \times 1) + (37 \times 2) + (44 \times 3) + (44 \times 4) + (47 \times 5) = 104 + 40 + 74 + 132 + 176 + 235 = 761104+(40×1)+(37×2)+(44×3)+(44×4)+(47×5)=104+40+74+132+176+235=761 Checksum=761mod??103=38\text{Checksum} = 761 \mod 103 = 38Checksum=761mod103=38 The check character value 38 corresponds to a specific pattern in the Code 128 character set. |
4. Stop Character The stop character in Code 128 has a predefined pattern. |

|
Example: Encoding 'HELLO' in Code 128 B |
1.Start B (104) 2.H (40) 3.E (37) 4.L (44) 5.L (44) 6.O (47) 7.Checksum (38) 8.Stop Character |

|
Barcode Representation |
Each character (including start, data, checksum, and stop) is translated into a series of bars and spaces of varying widths. A typical Code 128 barcode representation for 'HELLO' in subset B would look like this: | | | || | ||| || || ||| | | || | ||| | || | | ||| | || || || | || || | | || || | Each bar and space width is represented by 1 to 4 modules (1 being the narrowest and 4 the widest), and the entire sequence forms the complete barcode that scanners read. |
Applications |
Code 128 B is widely used in logistics, inventory management, and retail due to its ability to encode both letters and numbers compactly. It is particularly useful when space is limited and high data density is required. |

|
Summary |
Code 128 B is a versatile and efficient barcode standard capable of encoding a comprehensive set of characters. It includes a robust error-checking mechanism and is suitable for various applications where both alphanumeric data needs to be encoded in a compact format. |