When a barcode scanner scans a barcode containing control characters (such as Carriage Return (CR), Line Feed (LF), or Tab (TAB)), the behavior depends on how the scanner is configured and the system that processes the scanned data. Control characters are non-printable and often used to control formatting, cursor movement, or line breaks, rather than being visually represented. Below is a detailed explanation of what happens when a barcode scanner scans a barcode with control characters added. |

|
1. How Barcode Scanners Interpret Control Characters |
Barcode scanners are designed to decode and transmit the data encoded in a barcode. Most barcode scanners treat all encoded data as raw data, which means they interpret the control characters as their respective ASCII codes (or byte values). Here's how scanners typically behave: |
1.Raw Data Output: |
The barcode scanner reads the encoded barcode, interprets the control characters as their ASCII values (or byte sequences), and sends the corresponding data to the connected device (e.g., a computer, POS system, or terminal). |
Control characters like CR (Carriage Return, ASCII 13), LF (Line Feed, ASCII 10), and TAB (ASCII 9) do not have visual representations but are transmitted as raw ASCII codes. |
2.Processing Control Characters: |
Carriage Return (CR, ASCII 13): This character moves the cursor to the beginning of the current line (i.e., it 'returns' the cursor to the leftmost position). |
Line Feed (LF, ASCII 10): This character moves the cursor down to the next line. It is commonly used in combination with CR to create a new line (especially in Windows environments). |
Tab (TAB, ASCII 9): This character moves the cursor to the next tab stop (usually 4 or 8 spaces, depending on system configuration). |

|
2. Scanner and System Configuration |
How the control characters are processed after scanning depends on the configuration of the barcode scanner and the system receiving the data. |
2.1. Scanner Configuration |
Basic Mode (Raw Output): In the simplest configuration, the scanner is set to output raw data directly to the connected system. The scanner will transmit the control characters as part of the data stream. For example, if the scanner reads a barcode with CR (0x0D), LF (0x0A), or TAB (0x09), those characters will be transmitted as they are, and the receiving system will be responsible for interpreting them. |
Programmable Scanners: Many barcode scanners are programmable, meaning you can customize how they handle certain types of input. Some scanners can be configured to: |
Interpret control characters: The scanner can be set to handle control characters in a specific way, such as sending a specific action (like 'next field' or 'carriage return') when a control character is detected. |
Filter out control characters: In some cases, you may not want to send raw control characters to the receiving system. Some scanners can be programmed to ignore certain control characters or replace them with visible symbols. |
2.2. System Configuration |
Text Display: When a system (such as a terminal, a text-based interface, or a word processor) receives control characters, it interprets them based on their respective functions: |
CR: Moves the cursor to the beginning of the line (in systems that support CR). |
LF: Moves the cursor to the next line (in systems that recognize LF as a line break). |
TAB: Aligns the cursor to the next tab stop, typically used for aligning text in tables or forms. |
If you're scanning a barcode with both printable and control characters into a terminal window or word processor, the control characters will produce effects similar to typing them manually. For example: |
Scanning a barcode with a CR after a string of characters will move the cursor to the start of the line. |
Scanning a barcode with an LF will move the cursor to the next line. |
Scanning a barcode with a TAB will space the text out to the next tab stop. |
Data Processing Systems: In a more complex system, like a database or enterprise application, control characters might be used for purposes such as: |
Field Delimiters: A TAB character might separate fields in a delimited dataset (similar to CSV files). |
Formatting: CR and LF characters might be used to control the formatting of the data before it's displayed, printed, or logged. |
Serial Communication: Systems receiving barcode data could use CR and LF to delineate commands or data in a communication protocol, where CR signals the end of a command, and LF indicates the start of a new line of input. |

|
3. Practical Examples of Scanned Data |
Let's consider practical examples of what happens when a barcode with control characters is scanned, depending on the type of application or environment: |
Example 1: Inventory Management System (Scanning for Report) |
Encoded Data: |
Item ID: 001Quantity: 5Price: $10.00Item ID: 002Quantity: 3Price: $15.00 |
Expected Scanner Output: After scanning, the system receiving the data might display the output as: |
Item ID: 001 |
Quantity: 5 Price: $10.00 |
Item ID: 002 |
Quantity: 3 Price: $15.00 |
The Carriage Return (CR) moves the cursor to the beginning of the line after the Item ID. The Line Feed (LF) moves the cursor down to the next line. The Tab (TAB) aligns the fields 'Quantity' and 'Price' properly on the same line. |

|
Example 2: Text-Based Terminal (Control of Cursor Movement) |
Encoded Data: |
Name: JohnAge: 30Location: NYZip: 10001 |
Expected Scanner Output: |
Name and Age appear on separate lines due to the Line Feed (LF). |
The Carriage Return (CR) ensures that Location starts at the beginning of the current line. |
The Tab (TAB) indents Zip to the next tab stop. |
The terminal will display: |
Name: John |
Age: 30 |
Location: NY Zip: 10001 |

|
Example 3: Receipt Printer (CR, LF for Line Breaks) |
Encoded Data: |
Product: Widget APrice: $5.99Qty: 2Total: $11.98 |
Expected Scanner Output: The receipt printer will format the receipt as follows: |
Product: Widget A |
Price: $5.99 |
Qty: 2 Total: $11.98 |
The Carriage Return (CR) and Line Feed (LF) ensure each piece of information is on a new line, while the Tab (TAB) aligns the quantity and total on the same line. |
4. Potential Issues and Considerations |
While control characters provide a convenient way to format data, there are potential issues that could arise when barcode scanners process them: |
4.1. Incompatible Systems: |
Some older systems or less sophisticated barcode scanners might not properly interpret control characters or might not handle them as expected, leading to formatting errors or confusion in the output. |
4.2. Unintended Actions: |
If the barcode scanner or receiving system is not configured to handle control characters properly, scanning a barcode with CR, LF, or TAB might result in unintended actions. For example, a Carriage Return might unexpectedly overwrite data in a form field, or a Line Feed might break the data inappropriately. |
4.3. Barcode Reader Settings: |
Many barcode readers allow users to configure how control characters are treated. If you are designing a system where control characters will be used, you need to ensure that the barcode scanner is set up to handle these characters correctly, whether that means interpreting them or passing them through as raw data. |

|
Conclusion |
When a barcode containing control characters such as CR, LF, or TAB is scanned, the barcode scanner typically transmits these characters as part of the raw data. The receiving system then processes these characters based on its configuration: |
CR (Carriage Return) moves the cursor to the beginning of the line. |
LF (Line Feed) moves the cursor to the next line. |
TAB (Tab) moves the cursor to the next tab stop. |
Depending on the application and system configuration, the scanned data may result in formatted output, cursor movements, or data alignment. It's important to ensure that both the scanner and the system receiving the data are properly configured to interpret control characters as intended. |