Barcode Technology

Barcode History

Barcode Label Paper

Barcode Printer

Barcode Application

Inventory Management

AI Barcode QRCode

Barcode Scanner

Barcode Software

Barcode Software B

Barcode Software C

Barcode Software D

Barcode Software E

New Technology A

New Technology B

Robot Technology

Barcode Types

Barcode Types B

Barcode Types C

Barcode Types D

Barcode Types E

Barcode Types F

Electronic Technology

Psychology at Work

Barcode Technology and Barcode Software Related   <<< Back to Directory <<<

Code 128 Barcodes: A Technical Deep Dive and Industry-Wide Integration with ERP Systems (P4)

Code 128 Barcodes: A Technical Deep Dive and Industry-Wide Integration with ERP Systems

Chapter 4: The Shift and Code-Switch Logic

Short Summary - Chapter 4 at a Glance

This chapter explains one of the most powerful but least understood features of the Code 128 barcode symbology: its ability to change character sets on the fly within a single barcode. Unlike older barcode types that lock into one fixed character table, Code 128 uses special non-printing characters called FNC4 and Code-Switch codes to dynamically shift between three different character sets (Set A, Set B, and Set C). This logic allows a single barcode to contain uppercase letters, lowercase letters, control characters, punctuation, and long runs of pure numbers - all in the most space-efficient way possible. We will walk through how this works in plain language, with no formulas or tables. Then we will explore more than a dozen real-world American business examples, from hospital wristbands and shipping labels to automotive parts tracking and government asset management. By the end, you will see that these shift and switch codes are not obscure technical trivia; they are the silent workhorses that make Code 128 the universal choice for enterprise resource planning (ERP) systems across the United States.

1. The Three Faces of Code 128

To understand shift and switch logic, we first need to know that Code 128 is not one character set but three. Think of it as a multilingual translator that can speak three dialects: Set A, Set B, and Set C.

Set A is the 'industrial' dialect. It includes all standard uppercase letters (A-Z), digits (0-9), punctuation like period and comma, and a full range of control characters - the non-printable codes that old computer terminals used for carriage return, line feed, tab, and so on. Set A is great when you are encoding commands for printers or scanners, or when your data is mostly uppercase with some numeric fields.

Set B is the 'everyday' dialect. It also has uppercase letters, digits, and punctuation, but instead of control characters, it gives you lowercase letters (a-z). This is the most common starting point for human-readable text like names, addresses, and product descriptions. If you have mixed case, Set B is your friend.

Set C is the 'numeric' dialect. It does not store letters at all. Instead, it stores pairs of digits - two numbers at a time - in a single barcode character. That means a long string of numbers, like a serial number or a purchase order ID, can be packed twice as densely as in Set A or B. For example, the number '123456' takes six characters in Set A or B, but only three code characters in Set C (12, 34, 56). This density saves horizontal space, which is critical when you have limited label real estate.

Now, here is the catch: a barcode scanner does not automatically know which set you are using. That is why every Code 128 barcode starts with a start character - Start A, Start B, or Start C - to tell the scanner which dialect to use from the very first symbol. But what if your data contains a mix of uppercase, lowercase, and long numbersYou could choose Set B and encode everything, but the numbers would be fat and wasteful. Or you could choose Set C for the numbers, but then you cannot encode letters at all. The solution is the shift and switch logic - the ability to change dialects in the middle of the barcode without confusing the scanner.

2. The Two Tools: Shift and Switch

Code 128 gives us two distinct mechanisms to change character sets mid-stream. They are often confused, but they serve very different purposes.

The first mechanism is the 'Shift' character, officially called FNC4 (Function Code 4) in some contexts, but more precisely, Code 128 has a dedicated Shift code (value 98 in Set A and Set B) that temporarily flips to the other set for exactly one character. Think of it like a keyboard shift key - you press it, type one letter, and then it automatically reverts to the previous set. For example, if you are in Set B (which has lowercase) and you need a control character that only exists in Set A, you insert a Shift code before that one control character. After that single character, the scanner goes back to Set B. This is useful for occasional outliers - you do not want to switch the entire barcode for just one special symbol.

The second mechanism is the 'Switch' code, also known as Code-Switch or Set Change. There are three switch characters: Code A, Code B, and Code C. Unlike Shift, a Switch is permanent for the rest of the barcode (or until another Switch occurs). When you encounter a Code B switch while in Set A, you move to Set B and stay there until you explicitly switch again. This is like changing the keyboard layout from English to Spanish for an entire paragraph. Switches are efficient when you have large blocks of data that belong to a different set - for example, a long numeric serial number followed by a long mixed-case description. You switch to Set C for the numbers, then switch to Set B for the text.

The brilliance of Code 128 is that these shift and switch codes are themselves represented as normal barcode patterns. The scanner decodes them as commands, not as printable data. They do not appear in the human-readable interpretation; they are invisible to the user. But they are critical for the ERP system receiving the scan, because they ensure that every character is interpreted with the correct meaning.

3. How the Scanner and ERP Handle These Commands

When a barcode scanner reads a Code 128 symbol, it processes the stream of code words sequentially. The start character initializes the current set. As the scanner moves through the barcode, it maintains an internal state - 'currently in Set A', 'currently in Set B', or 'currently in Set C'. When it sees a Shift code, it temporarily changes state for exactly one code word, then reverts. When it sees a Code A, Code B, or Code C switch, it changes the state permanently. At the end, the scanner outputs a string of decoded characters - all printable - and sends that string to the connected device (a point-of-sale terminal, a warehouse handheld, or directly to an ERP system via middleware).

From the ERP system's perspective, it does not care about the shift or switch codes at all. The scanner has already done the heavy lifting. The ERP receives a clean ASCII string: letters, digits, punctuation, and maybe a few control characters if they were intentionally encoded. The ERP validates that string against its database - for example, looking up a part number, a work order, or a shipping ID. The beauty is that the same barcode can contain a complex mixture of data types without any extra delimiters or parsing rules, because the shift/switch logic guarantees that each character is correctly represented.

However, there is a subtle point: the ERP system must know the expected data format for each barcode type. If a barcode is supposed to be a serial number with letters and digits, the ERP will accept the decoded string as-is. If the barcode contains control characters (like ASCII 29 - Group Separator) to separate fields, the ERP must be programmed to split on those control characters. That programming is independent of the barcode symbology; it is a business rule. The shift/switch logic merely enables the barcode to include those control characters in the first place.

4. Real-World American Example 1: Hospital Patient Wristbands

Let us start with a classic example in the US healthcare industry. A major hospital system in Texas uses Code 128 wristbands for every admitted patient. The wristband barcode must encode: the patient's medical record number (a 10-digit numeric ID), the patient's last name and first initial (uppercase and lowercase, e.g., 'SmithJ'), and a two-digit ward code, plus an ASCII control character (RS - Record Separator, value 30) to separate these fields for the electronic health record (EHR) system.

The barcode designer starts with Set B because most of the text is mixed case. The first field is the 10-digit number. Encoding that in Set B would take 10 code characters - not terrible, but the wristband is small. Instead, they use a Start C at the beginning to encode the 10 digits as five code pairs (e.g., 12 34 56 78 90). Then they insert a Switch to Set B to encode 'SmithJ'. But wait - 'SmithJ' contains lowercase and uppercase, so Set B is perfect. After that, they need the two-digit ward code. They could stay in Set B, but to save space, they insert a Switch to Set C again just for those two digits, encode them as one pair, and then they need the Record Separator control character. That control character is only available in Set A. So they insert a Shift code (temporary) to Set A, encode the RS, and then the scanner reverts to Set C automatically. Finally, they end with a Stop character.

The resulting barcode is extremely compact. The ERP (the hospital's EHR system) receives a decoded string that looks like: '1234567890SmithJ05' with an invisible RS between the number and the name, and another RS before the ward code. The EHR splits on those RS characters and populates the admission record. The patient's name is correctly cased, the numbers are dense, and the control character does not print but is preserved. This wristband is scanned dozens of times per day for medication administration, lab draws, and meal delivery. The shift/switch logic ensures that one tiny label carries all necessary data without errors.

5. Real-World American Example 2: Automotive Parts Labeling in Michigan

A tier-one automotive supplier near Detroit ships thousands of brake calipers daily to a major car manufacturer. Each caliper has a 14-character alphanumeric serial number that follows a strict pattern: first two letters (plant code, uppercase), next eight digits (production date and sequence), and last four characters - a mix of letters and digits for quality batch. Additionally, the label must include a 6-digit purchase order number and a 2-digit line station code. The ERP system (SAP) expects these three fields concatenated with a tab character (ASCII 9) as the delimiter.

The barcode team decides to use Code 128 because of its flexibility. They start with Set B, since the serial number begins with uppercase letters. They encode the first two letters, then they realize the next eight digits would be more efficient in Set C. So they insert a Switch to Set C, encode eight digits as four pairs, then they need the last four mixed characters - which include both letters and digits. Set C cannot do letters, so they insert a Switch back to Set B and encode those four characters. Now they need a tab character - a control character only in Set A. They insert a Shift code (temporary) to Set A, encode the tab, and automatically return to Set B. Then they encode the 6-digit purchase order - again, they switch to Set C for three pairs, then Shift to Set A for another tab, then back to Set B for the 2-digit station code (which is just digits, but they stay in Set B because it is only two characters - switching to Set C would save only one code character, not worth the overhead).

The final decoded string sent to SAP is: 'AB2024031501X9T' + tab + '987654' + tab + '03'. The scanner handheld interprets the shift/switch internally and outputs exactly that string. SAP parses the tabs and routes the caliper to the correct assembly line. This barcode is printed on a high-temperature polyester label and survives paint oven curing. The plant manager loves that they never have to re-scan due to misreads, because the shift logic makes the encoding robust. Without the switch to Set C for the long digit runs, the label would have been 20% wider, forcing them to use larger labels that would not fit on the caliper's flat surface.

6. Real-World American Example 3: E-Commerce Fulfillment Centers in California

A large online retailer with a fulfillment center in Ontario, California, handles millions of packages per week. Each shipping label contains a Code 128 barcode that encodes the tracking number, the customer's zip code, and a sortation center code. The tracking number is a 20-digit numeric string (UPS or FedEx style). The zip code is 5 digits (plus 4-digit extension sometimes). The sortation code is a 3-letter uppercase airport code (e.g., LAX, DFW, JFK). The retailer's warehouse management system (WMS) also requires a single ASCII group separator (GS, value 29) between each field so that the automated sorting machines can parse the barcode quickly.

The barcode generator uses Start C because the vast majority of the data is numeric - the 20-digit tracking and the zip code. It encodes the 20 digits as 10 pairs, then the 5-digit zip as 3 pairs (with a leading zero if needed - but here they pad to 6 digits to make pairs). Then they need the 3-letter airport code, which is uppercase letters - only available in Set A or B. They switch to Set A (since uppercase is in both, but Set A also has the GS control character, so they choose Set A for consistency). They encode the three letters, then they need the GS delimiter - already in Set A, so no shift needed. Then they switch back to Set C for the next numeric field. The final decoded string looks like: '12345678901234567890' + GS + '91762' + GS + 'LAX'.

The automated conveyor belt scanners read this barcode at 500 feet per minute. The scanners are configured to interpret GS as a field separator and pass the three tokens to the WMS. The WMS then diverts the package to the correct trailer door for LAX-bound freight. The shift/switch logic here saves about 30% of label width compared to encoding everything in Set B. That means the retailer can use smaller, cheaper thermal labels and fit more barcodes on a single shipping document - a huge cost saving at their volume of 50,000 packages per day.

7. Real-World American Example 4: US Department of Defense Asset Tags

The US Department of Defense (DoD) mandates Code 128 for many asset identification tags under the MIL-STD-130 standard. A typical asset tag for a communication radio encodes the National Stock Number (NSN) - a 13-digit numeric code - the serial number - which can be alphanumeric, up to 15 characters, often with both cases - and a two-character maintenance command code. Additionally, the tag must include a non-printable End-of-Text control character (ETX, value 3) to signal the end of the data to legacy inventory systems.

The barcode is generated with Start C for the 13-digit NSN. Since 13 is odd, they pad a leading zero to make 14 digits, encoded as 7 pairs. Then they switch to Set B for the serial number, which might be something like 'RADIO-7A3b' - mixed upper, lower, and hyphen. Set B handles this perfectly. Then they need the two-character command code, which is uppercase, so they stay in Set B. Finally, they need the ETX control character - only in Set A. They insert a Shift code to Set A, encode ETX, and the scanner reverts to Set B.

The DoD's ERP system (which is a customized SAP instance) receives the decoded string: '0001234567890RADIO-7A3bMC' + ETX. The ETX is invisible but acts as a termination marker. The inventory handhelds are programmed to read until ETX, then validate the checksum. This barcode is laser-etched onto aluminum plates attached to the radio chassis. The shift/switch logic is critical because the serial number often contains lowercase letters (per manufacturer's format), and the NSN is purely numeric. Without switching to Set C for the NSN, the tag would need to be larger, which is not feasible on compact military equipment. The DoD has reported a 99.97% first-read rate across all branches, thanks in part to the efficient encoding enabled by these control characters.

8. Real-World American Example 5: Grocery Distribution Centers in Florida

A large grocery chain's distribution center in Orlando uses Code 128 barcodes on every pallet of produce. The pallet label encodes the purchase order (PO) number - a 10-digit numeric - the supplier's USDA grower code - a 5-character alphanumeric (e.g., 'A12B3') - the pack date - 6 digits (MMDDYY) - and a 4-digit store routing number. The grocery ERP (an IBM iSeries system) expects these four fields separated by a vertical bar '|' character (ASCII 124), which is printable and available in all sets, so no control characters needed.

The barcode generator starts with Set C because the PO and pack date and routing are all numeric - that is 10+6+4 = 20 digits, which become 10 code pairs. That is extremely efficient. Then they need the grower code with letters and digits. They insert a Switch to Set B (since it has both upper and digits) and encode 'A12B3'. Then they need the vertical bar delimiter - but vertical bar is available in Set B as well, so they can just encode it directly. However, they want the delimiter to be consistent after every field. They could stay in Set B for the rest, but that would waste space on the long numeric PO. So after the grower code and the first bar, they switch back to Set C for the pack date, then encode the pack date as 3 pairs, then switch to Set B for the bar, then switch to Set C for the routing number, then encode the routing number as 2 pairs, then finally a bar in Set B.

But there is a smarter approach: they encode all numeric fields contiguously with a single switch, and insert the bars using Set B switches. The actual sequence might be: Start C, encode PO (5 pairs), Switch to Set B, encode bar, Switch to Set C, encode pack date (3 pairs), Switch to Set B, encode bar, Switch to Set C, encode routing (2 pairs), Switch to Set B, encode bar, Switch to Set B (already there) for the grower codeWait - the grower code has letters, so they need to be in Set B. They can place the grower code at the end: after all numbers and bars, switch to Set B and encode 'A12B3'. That uses one switch. The decoded string is '1234567890|060124|4321|A12B3'.

The warehouse scanners read this barcode and the ERP splits on the vertical bar. The shift/switch logic saves roughly 40% of the barcode length compared to an all-Set-B encoding. On a typical day, they print 10,000 pallet labels, and the smaller barcodes mean less ink and faster print speeds. The produce managers appreciate that the labels are easy to scan even when wet from condensation, because the narrow bars leave more white space around them for contrast.

9. Real-World American Example 6: Pharmaceutical Serialization in New Jersey

A pharmaceutical company in New Jersey is required by the Drug Supply Chain Security Act (DSCSA) to encode a unique product identifier on each salable unit. The identifier is a 20-character alphanumeric serial number that includes a product code (5 digits), a batch number (6 alphanumeric, often with lowercase), and a 9-digit random serial. They also need to encode the expiration date (6 digits MMDDYY) and a lot control character - the ASCII 'US' (Unit Separator, value 31) - to delimit fields for their track-and-trace ERP.

They use Start C for the initial product code and the 9-digit serial - that is 14 digits total, which is 7 pairs. Then they need the batch number, which has mixed case - e.g., 'B12a4C'. They switch to Set B and encode that. Then they switch back to Set C for the expiration date (3 pairs). Then they need the US separator - only in Set A - so they insert a Shift to Set A, encode US, and revert to Set C. But they also need a second US after the expiration date. They insert another Shift. Finally, they want to include a checksum character that is a letter - they stay in Set B for that.

The final decoded string is: '12345' + '678901234' (the serial) but actually with the batch in between - let's simplify: the scanner outputs '12345678901234567890B12a4C060124' with US characters between fields. The ERP parses this and validates against the blockchain-based track-and-trace system. The shift/switch logic is essential because the batch number is not predictable - it can have lowercase letters that Set A does not support, and the long numeric runs are too wide if encoded in Set B. The company has reduced label waste by 25% since adopting this optimized encoding, and they have passed multiple FDA audits with zero barcode-related discrepancies.

10. Real-World American Example 7: Rental Car Fleet Management in Arizona

A national rental car company with a hub at Phoenix Sky Harbor Airport uses Code 128 barcodes on every key fob and windshield sticker. The barcode encodes the rental agreement number - a 12-character alphanumeric with both cases (e.g., 'AZ7890Xy12') - the vehicle identification number (VIN) - which is 17 characters, mostly letters and digits, but no lowercase - and a 4-digit mileage code. They also need a carriage return (ASCII 13) as a delimiter for their legacy mainframe system.

The designer starts with Set B because the agreement number has mixed case. They encode the first few characters, but then they realize the VIN is 17 characters - long. However, VINs are uppercase and digits, which are available in Set A and B. But they want to use Set C for the digits within the VINNot possible because the VIN is not purely numeric. Instead, they choose to stay in Set B for the entire VIN, but they use a Shift to Set A just for the carriage return delimiter. The agreement number and VIN are all printable, so no other switches are needed. The barcode ends up being moderate in length - about 30 code characters.

But there is a twist: the mileage code is four digits, and they want to save space. They switch to Set C just for those four digits (two pairs) right before the carriage return. The sequence: Start B, encode agreement number, encode VIN (no switch), switch to Set C for mileage, then Shift to Set A for carriage return (since Set C does not have control chars), then stop. The decoded string is 'AZ7890Xy121G1GC4G123456789' + CR + '1234'. The mainframe splits on CR and updates the rental record. The shift to Set C for mileage saves only two code characters, but on millions of rentals per year, that small saving reduces printing time and scanner processing. The rental agents report that the barcodes scan instantly even under bright desert sunlight, thanks to the consistent module widths that Code 128 provides regardless of set changes.

11. Real-World American Example 8: Library Book Tracking in Ohio

A public library consortium in Columbus, Ohio, uses Code 128 barcodes on all books and media. Each barcode encodes the item's 14-digit ISBN (which is numeric, but sometimes includes an 'X' for check digit - so alphanumeric) plus a 6-digit branch location code (numeric) and a 2-character collection code (e.g., 'YA' for young adult, 'NF' for nonfiction). The library's ERP (an integrated library system from a US vendor) expects these fields separated by a comma (ASCII 44) - a printable character.

The ISBN often has an 'X' at the end, so it is not purely numeric. They start with Set B to handle the 'X'. They encode the entire ISBN as-is - that is 14 characters. Then they need a comma - available in Set B. Then they encode the 6-digit branch code. To save space, they switch to Set C for that 6-digit number (3 pairs), then a comma - but comma is not in Set C, so they switch back to Set B for the comma, then switch to Set C for the collection codeNo, collection code is letters, so they switch to Set B for the two letters. The optimal sequence: Start B, encode ISBN, encode comma (in B), switch to Set C, encode branch code (3 pairs), switch to Set B, encode comma, encode collection code.

The decoded string is '978123456789X,123456,YA'. The library's handheld scanners are older models that do not cache set states, but Code 128's explicit switches ensure they never misinterpret a character. The shift/switch logic is especially helpful here because the ISBN is a mix of digits and a letter, so Set C cannot be used for the entire ISBN; but the branch code is pure digits, so switching to Set C for that segment cuts the barcode length by half for that field. Over 2 million items, the library estimates they save about 15% on label material costs annually.

12. Real-World American Example 9: Parcel Lockers in Urban Apartment Buildings

A company that operates smart parcel lockers in New York City apartment buildings uses Code 128 barcodes on delivery notice cards. The barcode encodes the locker number (a 3-digit numeric), the tenant's unit number (alphanumeric, e.g., '4B' or '12A'), the delivery carrier code (2 uppercase letters, e.g., 'UPS', 'FED'), and a 10-digit tracking number. They also include a non-printable 'ENQ' (Enquiry, ASCII 5) control character as a separator for their cloud-based ERP.

They start with Set C for the locker number and tracking number - the locker is 3 digits (pad with leading zero to make 2 pairsActually 3 digits is odd - they can pad to 4 digits as two pairs, or encode the locker as a single digit in Set CSet C always requires pairs. They pad '012' as '01' and '2' - no, better: they encode the 3-digit locker as one pair '01' and the '2' as a single digit in Set B later. Simpler: they start with Set B, encode the locker as '012' (three chars), then they need the separator - they switch to Set A for ENQ (since Set A has control chars), then they need the tenant unit - which has mixed case and digits - so they switch to Set B, encode '4B', then they need another ENQ - Shift to Set A, then carrier code - stay in Set B, then ENQ - Shift to Set A, then tracking number - 10 digits - switch to Set C for 5 pairs, then stop.

However, this sequence has many shifts. A better approach: use Set B as the base, and only switch to Set C for the tracking number. For the separators, use a printable character like '|' instead of ENQ, to avoid shifts. But the company's legacy system requires ENQ, so they must use it. They end up with: Start B, encode locker (3 chars), Shift to Set A for ENQ (reverts to B), encode tenant unit, Shift to A for ENQ, encode carrier, Shift to A for ENQ, Switch to Set C, encode 10-digit tracking (5 pairs), stop. The decoded string includes invisible ENQ characters. The ERP splits on ENQ and routes the delivery to the correct locker. The shift logic is used heavily here - about 3 shifts per barcode - but each shift adds only one code character overhead, which is acceptable. The lockers have small label printers that produce 2-inch-wide labels, and the efficient Set C for tracking keeps the barcode within that width.

13. Real-World American Example 10: Railroad Car Maintenance in Nebraska

A freight railroad company in Omaha uses Code 128 barcodes on railcar maintenance records. Each barcode encodes the railcar number - a 6-digit numeric - the maintenance order number - a 10-character alphanumeric with uppercase and digits - the mechanic's badge ID - a 5-character alphanumeric with both cases - and a 2-digit inspection result code. They also need the ASCII 'STX' (Start of Text, value 2) and 'ETX' (End of Text, value 3) to frame the data for their mainframe.

They start with Set C for the railcar number (3 pairs). Then they need STX - only in Set A - so they Shift to Set A, encode STX, revert to Set C. Then they need the maintenance order - mixed upper and digits - switch to Set B, encode that. Then they need a delimiter - they use a comma - which is in Set B, so they just encode it. Then they need the badge ID - also mixed case - stay in Set B, encode it. Then comma - stay in B. Then inspection result (digits) - they switch to Set C for those 2 digits (one pair) to save space. Then they need ETX - Shift to Set A, encode ETX, stop.

The decoded string is '123456' + STX + 'MNT2024A' + ',' + 'AB12c' + ',' + '05' + ETX. The mainframe reads from STX to ETX and parses the commas. The shift/switch logic is crucial because the maintenance order often has letters that are not in Set A, and the railcar number is pure numeric. The railroad has deployed this system across 5,000 railcars, and they have reduced manual data entry errors by 90%. The barcodes are printed on durable vinyl and attached to the car's underframe, where they survive extreme cold and heat. The ability to include STX and ETX as control characters - which are not normally printable - is a unique advantage of Code 128's shift to Set A.

14. Real-World American Example 11: Military Clothing Store (Exchange) in Virginia

A military base exchange (BX) in Virginia uses Code 128 barcodes on uniform items. Each barcode encodes the stock keeping unit (SKU) - a 12-digit numeric - the size code - a 3-character alphanumeric (e.g., 'M', 'L', 'XL' - but they encode 'XL' as two letters) - the color code - a 4-character alphanumeric (e.g., 'ODG' for olive drab, 'BLK' for black) - and the unit price in cents - a 5-digit numeric. They also need a 'CAN' (Cancel, ASCII 24) control character as a terminator for their point-of-sale (POS) system.

The POS system expects the fields in fixed lengths, so no delimiters are needed - just concatenation. The barcode generator starts with Set C for the 12-digit SKU (6 pairs). Then they need the size - which is letters - switch to Set B, encode 'XL' (or 'M' with padding - they pad to 2 chars). Then they need the color - switch to Set B (already there) encode 'ODG'. Then they need the price - 5 digits - they switch to Set C, but 5 is odd - pad with leading zero to 6 digits, encode as 3 pairs. Then they need the CAN control character - only in Set A - they Shift to Set A, encode CAN, and stop.

The decoded string is '123456789012XLODG001234' + CAN. The POS system reads the fixed lengths: first 12 digits, next 2 chars, next 3 chars, next 6 digits (ignore leading zero), and then the CAN signals end. The shift/switch logic allows this fixed-length encoding without any visible separators, which reduces barcode length. The BX processes thousands of transactions daily, and the small barcode fits on the price tag's limited space. The cashiers love that they do not have to manually enter sizes or colors, because the scanner decodes everything correctly regardless of case - Set B handles the uppercase letters perfectly.

15. Real-World American Example 12: University ID Cards in Massachusetts

A large university in Boston issues ID cards with Code 128 barcodes for campus access, meal plans, and library borrowing. Each barcode encodes the student's university ID - a 9-digit numeric - the student's last name (up to 15 characters, mixed case, e.g., 'O'Brien' - includes an apostrophe) - the graduation year (4 digits) - and a 2-digit campus code. They also include the ASCII 'FS' (File Separator, value 28) between fields for their ERP (Banner).

They start with Set C for the 9-digit ID - but 9 is odd, so they pad to 10 digits (leading zero) as 5 pairs. Then they need the last name - which has lowercase, uppercase, and an apostrophe - Set B is perfect. They switch to Set B, encode 'O'Brien' (the apostrophe is in Set B). Then they need FS - only in Set A - Shift to Set A, encode FS, revert to Set B. Then they need graduation year - 4 digits - they switch to Set C for 2 pairs, then Shift to Set A for another FS, then campus code - 2 digits - switch to Set C for 1 pair, then stop. They do not need a final FS because the ERP knows the field count.

The decoded string is '0123456789O'Brien' + FS + '2026' + FS + '03'. The campus access system reads the ID, the meal plan system reads the name for display, and the library system reads the graduation year for expiry. The shift/switch logic is vital because the name contains an apostrophe and mixed case - Set A cannot handle lowercase, and Set C cannot handle letters. By using Set B for the name and Set C for the numeric fields, they achieve a barcode that is about 35% shorter than an all-Set-B encoding. The university prints 20,000 new cards each year, and the smaller barcode leaves room for the student's photo and university logo on the same card.

16. Real-World American Example 13: Food Processing Plant in Iowa

A meat processing plant in Sioux City uses Code 128 barcodes on boxes of frozen beef patties. The barcode encodes the lot number - a 10-character alphanumeric with both cases and hyphens (e.g., 'BEEF-24A-b') - the production date - 6 digits (MMDDYY) - the shift code (a single letter, e.g., 'A' or 'B') - and the weight in pounds - a 4-digit number with one implied decimal (e.g., '1234' means 12.34 lbs). They also need a 'NUL' (Null, ASCII 0) control character as a separator for their inventory ERP - a legacy AS/400 system.

They start with Set B because the lot number has lowercase and hyphens. They encode the lot number fully. Then they need NUL - only in Set A - Shift to Set A, encode NUL, revert to Set B. Then they need the production date - pure digits - they switch to Set C, encode as 3 pairs, then Shift to Set A for another NUL, then shift backActually after the Shift to Set A for NUL, the state reverts to Set C (since they were in Set C). That is perfect. Then they need the shift code - a single letter - but they are in Set C, which cannot encode letters. They switch to Set B, encode the letter, then Shift to Set A for NUL, then switch to Set C for the weight (4 digits as 2 pairs), then stop.

The decoded string is 'BEEF-24A-b' + NUL + '060124' + NUL + 'A' + NUL + '1234'. The AS/400 splits on NUL and updates the inventory. The shift/switch logic here is used intensively - four shifts/switches per barcode - but the plant prints only 500 boxes per shift, so overhead is negligible. The real benefit is that the lot number can be human-readable and complex, while the numeric fields are densely packed. The plant has reported zero misreads in the past year, partly because the scanner's state machine handles these switches without any ambiguity.

17. Real-World American Example 14: Tire Manufacturing in South Carolina

A tire manufacturer in Greenville uses Code 128 barcodes on each tire sidewall. The barcode encodes the Tire Identification Number (TIN) - a 13-character alphanumeric (mostly digits, but ends with a letter for plant code) - the size code - a 6-character alphanumeric (e.g., 'P215/65R' - includes slash and letters) - and a 4-digit week/year code. They also need the ASCII 'ACK' (Acknowledge, value 6) as a delimiter for their quality control ERP.

They start with Set B because the size code has a slash and letters. They encode the size code first. Then they need the TIN - which is mostly digits but has a letter at the end - they could encode the digits in Set C and then switch to Set B for the final letter. But the TIN is 13 characters - the first 12 are digits, the 13th is a letter. They start in Set B for the size, then they switch to Set C for the first 12 digits (6 pairs), then switch to Set B for the final letter, then they need ACK - Shift to Set A for ACK, then the week/year - 4 digits - switch to Set C for 2 pairs, stop.

The decoded string is 'P215/65R' + '123456789012' + 'A' + ACK + '4321'. The ERP parses this by recognizing that the TIN is fixed length - it takes the first 13 chars after the sizeActually the size is variable, so they use ACK as the separator. The ERP splits on ACK and gets the TIN and week/year. The shift/switch logic is essential because the TIN's final letter would be inefficient in Set C, and the size code has a slash that is available in Set B but not Set A. The tire sidewall has limited curved space, so every millimeter of barcode width matters. This optimized encoding keeps the barcode within a 2-inch height, which is a requirement for the sidewall molding process.

18. Real-World American Example 15: Airport Baggage Handling in Chicago

O'Hare International Airport uses Code 128 barcodes on baggage tags for connecting flights. The barcode encodes the passenger's record locator - a 6-character alphanumeric with both cases (e.g., 'A1b2C3') - the flight number - a 4-digit numeric - the date - 6 digits (MMDDYY) - and the destination airport code - a 3-letter uppercase (e.g., 'ORD'). They also need a 'LF' (Line Feed, ASCII 10) as a separator for their baggage sorting ERP.

They start with Set B because the record locator has mixed case. They encode that. Then they need LF - only in Set A - Shift to Set A, encode LF, revert to Set B. Then they need the flight number - 4 digits - they switch to Set C for 2 pairs, then Shift to Set A for another LF, then date - 6 digits - switch to Set C for 3 pairs, then Shift to Set A for LF, then destination - 3 letters - switch to Set B, encode 'ORD', stop.

The decoded string is 'A1b2C3' + LF + '1234' + LF + '060124' + LF + 'ORD'. The sorting system reads this and routes the bag to the correct carousel. The shift/switch logic is heavily used - three shifts per barcode - but the tags are printed on demand at check-in kiosks, and the print speed is not a bottleneck. The real advantage is that the barcode is very compact - the record locator's mixed case is preserved, the numeric fields are dense, and the control characters are invisible to the passenger but essential for the automated system. O'Hare handles over 200,000 bags daily, and the barcode system has a read rate of 99.5%, reducing lost baggage incidents significantly.

19. Comprehensive Summary - Why Shift and Switch Matter

Now that we have seen fifteen diverse American applications, let us step back and synthesize the key lessons about Code 128's shift and switch logic.

First, the shift and switch codes are not optional decorations; they are fundamental to the symbology's density and flexibility. Without them, Code 128 would be just another limited barcode like Code 39, which can only encode uppercase letters, digits, and a few punctuation marks. With them, Code 128 becomes a universal data carrier that can handle virtually any ASCII string - from pure numbers to mixed-case text to control characters - while optimizing for minimum physical size.

Second, the practical benefit is measurable in every industry. In healthcare (Example 1), shifts allow control characters like RS to delimit fields without wasting label space. In automotive (Example 2), switches to Set C cut label width by 20%, enabling small parts labels. In e-commerce (Example 3), the combination of Set C for tracking numbers and Set A for GS separators allows high-speed sorting with minimal scanner processing. In defense (Example 4), the use of ETX ensures compatibility with legacy mainframes. In grocery (Example 5), vertical bar separators combined with Set C numeric packing reduce ink usage by 40%. In pharmaceuticals (Example 6), shifts enable Unit Separators that are required by track-and-trace regulations. In rental cars (Example 7), a simple switch for mileage saves printing time across millions of transactions. In libraries (Example 8), switches for branch codes cut label costs. In parcel lockers (Example 9), shifts for ENQ allow cloud ERP integration. In railroads (Example 10), STX and ETX frame data for mainframe safety. In military exchanges (Example 11), shifts for CAN terminate POS strings cleanly. In universities (Example 12), shifts for FS separate fields on crowded ID cards. In food processing (Example 13), NUL separators keep legacy AS/400 systems happy. In tire manufacturing (Example 14), shifts for ACK allow quality control parsing. And in airports (Example 15), shifts for LF enable automated baggage routing.

Third, the shift and switch logic is entirely transparent to the end user. The human-readable text printed below the barcode typically shows the decoded data without the control characters (or with their mnemonics), but the scanner and ERP see the full ASCII stream. This transparency means that system integrators can design complex barcode payloads without worrying about the scanner's internal state - as long as they follow the encoding rules. Most modern barcode generation software (like those integrated with ERP systems from SAP, Oracle, Microsoft Dynamics, and Infor) automatically handle the shift/switch optimization. The software analyzes the input string, determines the most efficient set transitions, and inserts the necessary Shift and Switch codes. The ERP developer only needs to specify the data fields and delimiters; the barcode engine does the rest.

Fourth, there is a trade-off between the number of shifts/switches and barcode length. Each switch code adds one character overhead; each shift also adds one character. For very short data strings, the overhead might not be worth it - you might just stay in Set B and accept a slightly wider barcode. But for long numeric runs, the savings from Set C far outweigh the overhead of two switches (one to enter, one to exit). Barcode generation algorithms typically compute the total length for multiple encoding strategies and choose the shortest one. This is done internally, so the user never sees the decision process.

Fifth, the control characters enabled by Set A are a hidden gem. In many ERP systems, delimiters like RS, GS, US, STX, ETX, NUL, CAN, ACK, LF, and ENQ are standard for legacy data interchange (e.g., ANSI X12, EDIFACT, or proprietary mainframe formats). Code 128 is one of the few barcode symbologies that can encode these non-printable characters. This makes it the preferred choice for government, defense, healthcare, and logistics where interoperability with old systems is mandatory. The shift to Set A is the only way to inject these characters, because Set B and Set C do not include them. Without the Shift character, you would have to use printable substitutes like '|' or ',' and then translate on the ERP side - which adds complexity and potential errors.

Sixth, the reliability of Code 128 with shifts and switches is exceptionally high. The barcode standard defines clear code words for each shift and switch, and the checksum algorithm (the mandatory modulo-103 check digit) covers the entire sequence including these control codes. That means any misread of a shift or switch would likely cause a checksum failure, triggering a rescan. In practice, modern scanners have error-correcting decoders that can disambiguate even damaged symbols. The examples from our fifteen applications all report first-read rates above 99%, which is a testament to the robustness of this logic.

Finally, from an ERP integration perspective, the shift and switch logic simplifies data capture. The ERP does not need to know the barcode's internal set transitions; it only receives the final ASCII string. This decoupling allows the barcode team to optimize label layouts without changing the ERP's parsing rules. For instance, if a company decides to change from a comma delimiter to a GS delimiter, they only update the barcode generation template; the ERP just splits on GS instead of comma. The shift/switch logic supports any delimiter without additional programming. This flexibility is why Code 128 has become the de facto standard for supply chain, manufacturing, retail, healthcare, and transportation in the United States.

20. Final Extended Summary - Putting It All Together

To conclude Chapter 4, let us revisit the core concepts in a broader context. Code 128's three character sets - A, B, and C - are like three toolboxes. Set A is the toolbox for industrial control and uppercase plus digits; Set B is the everyday toolbox for mixed-case text; Set C is the high-density toolbox for pure numbers. The Shift character is a temporary loan from one toolbox - you borrow a single tool and return it immediately. The Switch characters are permanent relocations - you move your entire workspace to a new toolbox and stay there until you move again.

This chapter has shown that these mechanics are not theoretical; they are deployed daily across the American economy. In hospitals, they ensure that patient identifiers contain both numeric IDs and correctly cased names with control separators. In factories, they shrink labels for automotive parts and tires, fitting barcodes onto curved or tiny surfaces. In warehouses, they allow high-speed sorting of e-commerce packages by packing long tracking numbers into half the space. In the military, they bridge the gap between modern scanners and legacy mainframes by embedding STX, ETX, and other control characters. In grocery distribution, they save ink and paper by using Set C for produce pallet numbers. In pharmaceuticals, they comply with federal serialization mandates while including batch letters and expiration dates. In rental car fleets, they speed up check-in and check-out by encoding alphanumeric agreements and numeric mileage in one scan. In libraries, they reduce label costs by switching to Set C for branch codes. In parcel lockers, they enable cloud-based routing with ENQ separators. In railroads, they frame maintenance data with STX/ETX for mainframe safety. In military exchanges, they terminate POS transactions cleanly with CAN. In universities, they fit complex student data onto ID cards with FS separators. In food processing, they talk to AS/400 systems using NUL delimiters. In tire plants, they use ACK for quality control. And in airports, they route millions of bags with LF-separated data.

The common thread across all these examples is that the shift and switch logic is invisible to the operator but indispensable to the system. It is the unsung hero that allows a single barcode to be many things at once: a numeric compact code, a text-rich label, and a control-character-driven message. Without it, you would need multiple barcodes or larger labels, or you would have to sacrifice data richness for space. With it, you get the best of all worlds.

For ERP architects, the key takeaway is to trust the barcode generation engine to handle the shift/switch optimization. Most enterprise barcode printers and label design software (like Zebra Designer, Bartender, NiceLabel, or Loftware) have built-in 'smart encoding' that automatically selects the most efficient set transitions. You do not need to manually insert Code A/B/C switches unless you are writing a custom low-level encoder. However, understanding the logic helps you design better data formats - for example, grouping all numeric fields together so the encoder can use fewer switches, or placing control characters at the ends of fields to minimize shifts.

From a scanner perspective, all modern CCD and laser scanners are fully compatible with Code 128 shifts and switches. The scanner's firmware implements the state machine as specified by the ISO/IEC 15417 standard. The decoded output is always a clean ASCII string. The only caveat is that some legacy scanners might output the shift/switch characters as special escape sequences if they are not configured in 'raw' mode, but that is a configuration issue, not a symbology limitation. In all of our American examples, the scanners were set to 'data capture' mode, which discards the control codes after decoding and delivers the intended ASCII characters.

Finally, we should acknowledge that while Code 128 is incredibly powerful, it is not the only symbology that uses shifts - GS1-128 is essentially Code 128 with Application Identifiers, and it leverages the same shift/switch logic. But Code 128 remains the foundation. Its shift and switch capabilities are what made it the preferred choice for the US Department of Defense, the automotive industry, and the healthcare sector. As we move into an era of IoT and real-time ERP, the ability to encode complex, delimited, mixed-case, and control-character data in a small, reliable barcode will only grow in importance.

In the next chapter, we will explore how these barcodes are physically printed and verified, and how the checksum computation works hand-in-hand with the shift/switch logic to guarantee data integrity. But for now, remember this: every time you scan a Code 128 barcode on a hospital wristband, a shipping label, a car part, or a library book, you are benefiting from a carefully choreographed dance of Set A, B, and C - a dance that happens in microseconds, without any human awareness, but with enormous impact on efficiency and accuracy. That is the genius of the shift and switch logic.

End of Chapter 4

 

EasierSoft Barcode Label Design & Bulk Printing Software

---- Use Excel Data to Batch Print Barcodes on Label Sheets or Roll Labels  

---- How to use this barcode software

Download:  Free Barcode Software + Barcode Label Designer

Download Free Barcode Software at Softonic

     Download at CNET

Once you obtain a GS1/UPC/EAN barcode, or other barcode type and QR code, you can use our free software to batch print barcode labels onto Roll label paper using a professional label printer, or to batch print barcodes onto Avery 5160 label sheets using a regular laser or inkjet printer. Our software has free and paid versions.

The free version fully meets your needs for batch printing GS1/UPC/EAN barcodes. The paid version can import data from Excel and databases to batch print barcode labels with different values.

How to Start

Input Data

Import Excel Data

Print Barcode

Barcode Format

Label Designer

All Screen Shot

Export Barcode Image

Save Template

Output Word Excel

How to Use & FAQ:

Barcode types supported by this program

Barcode Label Font Settings

Configuring the Barcode Print Rotation

Text Alignment for Barcode Labels

Automatically Adjusting Barcode Width

Text Beneath the Barcode

Configuring Barcode Size

Auto Calculate the Barcode Size

Export Barcode images

Export Barcode Image Format

File Names for Exported Barcode

Resolution of Exported Barcode Images

Fixed Folder for Exporting Barcode

Default Barcode Image Export Format

Print bulk barcodes quickly

Print barcodes to Avery 5160 label

How to bulk Barcode Printing

Sample - Avery 5162 (2x7) Label Sheet

Example: Print barcodes to 5*3cm roll

Example: Print barcodes to 5161 label

Example: Print barcodes to 5162 label

Example: Print barcodes to 5163 label

Example: Print barcodes to 5164 label

Example: Print portrait orientation 5164

Example: Print barcodes to 5167 label

Example: Print barcodes to 5168 label

Example: Print portrait orientation 5168

Example: Print barcodes to 5169 label

Example: Print barcodes to 5660 label

Example: Print barcodes to 5661 label

Example: Print barcodes to 5662 label

Example: Print barcodes to 5663 label

Example: Print barcodes to 5664 label

Example: Print portrait orientation 5664

Example: Print barcodes to 5873 label

Example: Print barcodes to 5874 label

Two ways to import Excel data

Import Excel Data - Pro Edition

Import Excel Data - Std Edition

Import Data from Excel - Detail

Load Data From Excel File

Data Editing Table

Copy Data From Excel

Four ways to input barcode data

Add ASCII Key E

Input Multiple Lines of Text for Barcodes

Generates Sequential Serial Numbers

Import or copy data from Excel sheets

Special sequence number generation

Std Details: Simple Input Form

Highlights

Excel integration: Import data directly from Excel to generate and print barcodes in bulk.

Label designer: Create complex labels with multiple barcodes, text, logos, and shapes.

Batch printing: Print thousands of barcodes at once using standard inkjet/laser printers or professional barcode printers.


Flexible editions:

Standard Edition: Simple batch printing with Excel data.

Professional Edition: Adds command-line automation for workflow integration.

Label Designer Edition: Advanced design features for complex labels.


Why Choose Our Barcode Solutions?

Cost-effective: Free online generator and permanent free desktop version available.

Easy to use: No technical expertise required—just input data and print.

Versatile: Supports nearly all 1D and 2D barcode types, including QR codes.

Trusted: Recommended by CNET and widely downloaded by users worldwide.


Suitable Use Cases

Small businesses and startups needing quick barcode labels for products.

Retailers and online sellers managing inventory with batch barcode printing.

Manufacturers requiring sequential or custom barcode labels for packaging.

Educational and testing environments where barcodes are used for tracking.

 

 

CONTACT

cs@easiersoft.com

If you have any question, please feel free to email us.

 

https://free-barcode.com

 

<<< Back to Directory <<<     Barcode Generator     Barcode Freeware     Privacy Policy