zerion

Scroll
Follow

Convert Hexadecimal to ASCII

If you need to convert hexadecimal data into an ASCII format, then the snippet below is for you. The form will contain two text elements (hex1) and (ascii).

Page Level Javascript:

function hex2a(hex)

{ var str = ''; for (var i = 0; i < hex.length; i += 2) str += String.fromCharCode(parseInt(hex.substr(i, 2), 16)); return str;}

When you enter hexadecimal data into (hex1), the function will convert that data into ascii format in the (ascii) field. This same function can be used when (hex1) is defined as a hardware widget to read data into the form.

 

Dynamic Value (hex1):

hex1="";

Dynamic Value (ascii): 

hex2a(hex1);

 

Enjoy!!

Thanks to this post for the code snippet.

    Was this article helpful?
    0 out of 0 found this helpful
    Have more questions? Submit a request

Comments

Powered by Zendesk