How Do I Convert a Hex String to a Normal String?

Updated Jun 22, 2018

Reported In

Software

  • LabVIEW

Issue Details

I have a string control represented as Hex Display. How can I convert it to a normal string indicator while keeping the hexadecimal notation?

Solution

In order to convert a hex string into a normal string, the hex string has to be converted into a byte array, which is indexed and converted into smaller hex strings of two digits. The smaller hex strings are then concatenated into a normal string. For some values, a two digit hex string will start with a zero. In this case, there is one digit (0-9) after converting to a hexadecimal string. Checking for the string length and prepending 0 if it has only one character will result in a proper conversion from hexadecimal to normal string.

See the attached VI for an example of the conversion process.

Another method is to use the Format Into String function and putting a %x constant in the Format String parameter. A similar check for bytes that start with zero (less than 10) needs to be performed, as seen in the following snippet: 

WAS THIS ARTICLE HELPFUL?

Not Helpful