PRB: Scanned Data is Incorrectly Displayed on Computer

SYMPTOMS

You connect barcode scanner to the computer with Italian keyboard layout through a keyboard wedge (such as USB interface). You encode 123-356-0940 in data matrix or Codabar, which is capable of encoding hyphen characters. You received the result as 123'356'0940.

CAUSE

Punctuation characters often have different virtual key codes among different locales. To enter punctuation characters correctly through a keyboard wedge interface, the scanner and the computer must use the same keyboard layout.

RESOLUTION

The Keyboard Country in your scanner must match the one on your computer with keyboard wedge interface. In this example case, you should configure Keyboard Country to Italy. This is usually done by scanning several barcodes in your scanner manual. For detailed information, see scanner manual for details.

STATUS

This behavior is by design.

MORE INFORMATION

Keyboard-wedge scanners emulate keyboard when reading barcodes. Four possible Windows messages are sent - WM_KEYDOWN, WM_KEYUP, WM_SYSKEYDOWN and WM_SYSKEYUP. Each message carries a Virtual Key Code that indicates which key is pressed. These messages are further processed through keyboard driver installed into WM_CHAR and WM_SYSCHAR messages, which are received by the application who owns the focus.

Generally speaking, each key on the keyboard has a virtual key code. However, not all printable ASCII values have their corresponding key codes. For example, Windows must rely on the status of Cap Locks and Shift to determine if KEY_A should be be mapped to capital case A or lower case a. Under this design, all keyboards have the same mechanics, and the differences are the key caps and corresponding keyboard drivers.

The Universal keys (i.e. always translated in the same way by keyboard drivers) are:

TAB, SPACE, 0-9, A-Z

and a number of function keys (F1-F12, Shift, Ctrl and so on).

Therefore, you may consider the fact when designing your application by restricting the character set of your data to digits and letters, if your application is going to be used in multiple locales.

Punctuation keys are often arranged differently among locales and therefore have different virtual key codes. Therefore to emulate these keys correctly the barcode scanners must be configured under the correct keyboard layout. If you use Italian keyboards, you must set the scanner's Keyboard Country to Italy in order to read punctuation letters correctly.

Figure 1. Keyboard Layout: U.S. vs Italian

Keyboard Layout: U.S. vs Italian

The figure above shows the right top portion of a standard US keyboard vs an Italian one. The minus key on a US keyboard corresponds to the single quote key on an Italian keyboard. A scanner configured as US keyboard emulation (which is default in most scanners) sends this key code to Windows upon reading barcode, and the Italian keyboard driver translates it into a single quote character.

To avoid these translation issues, you may consider using RSC-232 interface and read the data directly from the port, or through a wedge software that supports key translation.

APPLIES TO

  • All barcoding software

  • Microsoft Windows (All versions)