How to Convert Full-Width Alphanumeric Characters to Half-Width Alphanumeric Characters

Updated Oct 1, 2024

Reported In

Software

  • LabVIEW

Issue Details

Is there a way to convert full-width alphanumeric characters to half-width alphanumeric characters?

Solution

This conversion can be done programmatically. Obtain the byte value (ASCII value) of a full-width character and then rewrite the ASCII value to that of its half-width character.

Below are the equations for converting ASCII values from full-width to half-width characters.
Uppercase letters and numeric values use an equation that differs from lowercase letters.
 

Equation for uppercase letters and numeric values:
(ASCII value of full-width A-Z & 0-9) - 31 = ASCII value of half-width A-Z & 0-9

Equation for lowercase letters:
(ASCII value of full-width a-z) - 32 = ASCII value of half-width a-z

The VI snippet below converts the entered full-width alphanumeric characters to half-width characters.


Note: This image is a LabVIEW snippet, which includes LabVIEW code that you can reuse in your project. To use a snippet, right-click the image, save it to your computer, and drag the file onto your LabVIEW diagram.