Literal Hex to ASCII Conversion
TurnipTruck
Posts: 1,485
Greetings,
I am trying to translate a literal hex string to the ASCII characters it represents.
Example: '46726F6E74' needs to be translated to 'Front'
I have looked at FORMAT, HEXTOI, etc with no luck.
Any thoughts?
Thanks.
I am trying to translate a literal hex string to the ASCII characters it represents.
Example: '46726F6E74' needs to be translated to 'Front'
I have looked at FORMAT, HEXTOI, etc with no luck.
Any thoughts?
Thanks.
0
Comments
Assuming a single byte is represented always with 2 characters, only a self made function may do this.
If the byte values are matching the ASCII table, you'll get your "Text".
Should do that - theoredically . Don't have a master to test at the moment.....
HEXTOI('3132') -> 12594
ITOA(12594) -> '12594'
But if handling that 4 chars '3132' as "2 bytes" (what my function above may do), the result of the function is " '12' "
Other example:
HEXTOI('595A') -> 22874
ITOA(22874) -> '22874'
But the function result may be " 'YZ' "
Ok, don't see my message as "I have not seen the sarcasm" but as "I just wanted to show what's the difference for those who are interested" (n+1 )
The HEXTOI conversion works well. It may be recommended that the string which will hold the converted value not have its type defined. If declared as a CHAR array, you may get a compiler warning when you try to put an integer value into it.
DEFINE_VARIABLE
CHAR cORIGINAL_STRING[32]
cCONVERTED_STRING[16]
Thank you for your help.
Not declaring a type is the same as flat -out declaring it INTEGER; that's the default variable type. Maybe I'm just being nit-picky here, but if your problem is assigning an integer value to an array position that really ought to have a CHAR, you should fix it on the other end rather than making an integer array. TYPE_CAST() is made for just such situations as this.