• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Hex > Text
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hex > Text


  • Subject: Re: Hex > Text
  • From: "Arthur J. Knapp" <email@hidden>
  • Date: Wed, 17 Sep 2003 11:52:03 -0400

> Date: Tue, 16 Sep 2003 19:21:00 -0400
> From: Rob Jorgensen <email@hidden>
> Subject: Hex > Text

> Is it possible to convert the hex to text via the shell
> or vanilla AppleScript?

Yes.

Glad I could help.


> If so, sample code would be greatly appreciated....

Oh, right, good idea. ;-)


on HexToString(sHex)
try
-- do script ("+data TEXT" & sHex & ";")
--
+event miscdosc; ("+data TEXT" & sHex & ";")

on error
run script ("+data TEXT" & sHex & ";")

end try
end HexToString

HexToString("48656C6C6F20576F726C64") --> "Hello World"


The "run script" statement, as far as I know, works in all versions
of AppleScript and in all script editors.

The "do script" version is much faster than "run script," but only
seems to work in Script Debugger and Smile. The compromise is to use
the raw syntax of "do script," which is +event miscdosc;, and error
trap it. This allows it to compile in all of the third-party script
editors as well as Apple's script editor. Those editors that recognize
"do script" will, um... do the script, while those that don't will
use the slower but just as effective "run script."

on StringToHex(s)

set c to s as C string

try
err of c
on error msg
end try

return msg's text -((s's length) * 2 + 4) thru -5

end StringToHex

HexToString( StringToHex( "Hello World" ) ) --> "Hello World"



{ Arthur Knapp, of <http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m

"Love is like oxygen...."
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Hex > Text
  • Next by Date: Re: Hex > Text
  • Previous by thread: Re: Hex > Text
  • Next by thread: Re: Hex > Text
  • Index(es):
    • Date
    • Thread