I'm trying to create a barcode with a "TAB key" within it.
(It seems as though some generators use ~
as a TAB key.)
I've read that Code128 supports ASCII, meaning "HT" should work as a Horizontal Tab. But I can't seem to get it to work.
How do I store a HT character in a Code128 that will decode to a TAB key press?
Generating a Code 128 containing an ASCII control character
Code 128 can be used to encode any character in the Latin-1 character set, including ASCII control characters (ordinals 0 to 31).
Here is a Code 128 barcode representing a lone HT character (ASCII value 9):
The internal encoding uses code set A and contains these code words:
General effect of scanning barcodes containing ASCII control characters
Scanning any type of barcode containing ASCII control characters may not give the intended result due to the diverse ways that the barcode contents may be provided to the system. Each method will provide different ways to configure how control codes are presented to your application.
A hardware reader might be configured in "keyboard wedge" mode where the device emulates a physical keyboard by generating keyboard scan codes. In this case you can usually configure the device to provide specific "key sequences" before and after scanning, as well as provide a mapping from the Latin-1 ordinals (0-255) represented in a barcode to the physical scan codes read by the keyboard interface, For example, in a particular application one might choose to map Carriage Return (ASCII 13) to the Down Arrow (5000) scan code. This text describes the relationship between ASCII control characters and scan codes.
Alternatively a hardware or software reader may use a driver. There is a lot of variation with this approach but often they provide a synthetic RS232 interface (perhaps over USB) or hook into the OLE subsystem of the operating system. In the most basic case scanning a barcode would be equivalent to pasting some text into a textfield – you may require the device/software to perform some kind of translation of the raw barcode data and you may also need to modify the application to react appropriately to the input.
Consider for example that the result of pasting some text containing a HT character into a text field isn't necessarily the same as manually typing that same text on the keyboard, i.e. at some point actually pressing the TAB key. When pasting the text the result would likely be that the initial field would contain the full text including the literal HT character. When typing the text manually the result would likely be that the leading input goes into the initial field, then the TAB key-press results in a change of focus to the next field in the tab order, which the remainder of the text will populate.
A barcode reader's documentation should describe the interfaces available and methods for customising the presentation of scanned data.