Page 1 of 1

Converting Hex to ASCII

Posted: Sat May 21, 2016 12:28 am
by keithglong
Hi All,

I am trying to convert Hex to ASCII, similar to the Hex to ASCII Text Converter at:

http://www.rapidtables.com/convert/numb ... -ascii.htm

When I enter 57612be9 and click on the "Convert" button, I get the following value:

Wa+é

Using the binaryEncode function in LiveCode...

Code: Select all

answer binaryEncode("H*", "57612be9")
I get Wa+È

Any idea as to why that last character is off? Any feedback would be most welcome.

Thanks!

Sincerely,

Keith "Boo" Long
Gulf Breeze, Florida

Re: Converting Hex to ASCII

Posted: Sat May 21, 2016 6:10 am
by Ledigimate
Hi Keith

The last 2 hex digits correspond to the 233rd character of the Extended ASCII Character set, which may vary on different platforms and computers for several reasons. The web calculator most likely uses a different Extended ASCII Character set from that used by LiveCode on your computer.

However, you can be fairly confident that the actual *binary* value would be the same across all platforms. The difference comes in when the binary value is converted to text.

Here's a Wikipedia article explaining how such differences can be commonplace:

https://en.wikipedia.org/wiki/Extended_ ... _confusion

Kind regards,

Gerrie

Re: Converting Hex to ASCII

Posted: Sat May 21, 2016 9:15 am
by bn
Hi Boo,

ASCII 233 for Win/ISO is é
ASCII 233 for Mac is È

Apparently you are using a Mac and LC returns the Mac ASCII value

if you force LC to interpret ASCII 233 as ISO by using isoToMac it will translate to é

Code: Select all

answer isoToMac(binaryEncode("H*", "57612be9"))
a bit confusing.

I looked here:
http://academic.evergreen.edu/projects/ ... xt-mac.htm
http://academic.evergreen.edu/projects/ ... ext-pc.htm

Kind regards
Bernd

Re: Converting Hex to ASCII

Posted: Thu May 26, 2016 5:25 pm
by keithglong
Thanks guys!
However, you can be fairly confident that the actual *binary* value would be the same across all platforms.
Correct.

Warmest regards,

- Boo
Gulf Breeze, Florida