How to Convert String Containing Hexadecimal Number to Hexadecimal String

Updated Jan 31, 2019

Reported In

Software

  • LabVIEW

Issue Details

If I type a hexadecimal string into a normal text box, how can I convert it into the correct hexadecimal number, and not the hexadecimal version of the underlying ASCII?

Solution

This can be achieved by processing the normal string two characters at a time, two ways to achieve this are shown in this code.
 

Additional Information

In the upper branch, the string length is obtained and a logical shift used to divide it by two. The loop the converts the incoming string, two characters at a time, into hexadecimal format (%2x). This is then typecast back into a string before being displayed.

In the lower branch, the incoming string is typecast from a string into an array of U16 numbers. This is then converted array by array into hexadecimal in the loop, before being displayed on the output.

WAS THIS ARTICLE HELPFUL?

Not Helpful