LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Converting ascii to hex

How do you go about converting an ascii string to a string of corresponding hex values. ex. "C"-->"43" or "KC" --> "434B"
0 Kudos
Message 1 of 4
(10,983 Views)
I have attached a small LV 6i vi that seems to do the trick. Basically, it converts the string into byte array, then converts the byte array into an array of hexadecimal strings, then concatenates the elements of the hexadecimal string array into a single string.

Good Luck

Frank Carey
Message 2 of 4
(10,983 Views)
Find attached VI, it includes 2 different approaches. I wasn't sure about normal/reverse order in your final string, thus I coded both.

Good Luck!
0 Kudos
Message 3 of 4
(10,983 Views)
If you only want to display the hexadecimal content of a string, write it in an indicator and select the hexadecimal display with the right button menu.

If you need to convert the string, tt can be done using 3 LabVIEW functions, no loop:

ASCII String->String to Byte Array->Number to Hexadecimal String(length 2)->Concatenate Strings->Hexadecimal String.


LabVIEW, C'est LabVIEW

Message 4 of 4
(10,983 Views)