Hex String Handlers
Hex String Handlers
- Subject: Hex String Handlers
- From: Hudson Barton <email@hidden>
- Date: Thu, 26 Dec 2002 23:53:20 -0500
I have a little routine to convert an ascii string into its hex
equivalent, and another to reverse the process. It is very slow on
anything but the smallest text segment. I'm wondering if there is
any "Terminal" or shell alternative. No osaxen please. The "hex"
handler is below.
Thanks,
H.
on HexString(AString)
set thelist to {"0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", "A", "B", "C", "D", "E", "F"}
set L to length of AString
set hexvalue to ""
repeat with i from 1 to L
set theAscii to ASCII number of character i of AString
set theone to round (theAscii / 16) rounding down
set theremainder to theAscii + 1 - (theone * 16)
try
set Hexone to (item (theone + 1) of thelist) as string
on error
set Hexone to "O"
end try
try
set Hextwo to (item theremainder of thelist) as string
on error
set Hextwo to "O"
end try
set theHex to Hexone & Hextwo as string
set hexvalue to hexvalue & theHex as string
end repeat
set the clipboard to hexvalue
end HexString
--
N <>< <>< <>< Hudson Barton <>< <>< <><
| 205 Winsor Lane
\ / Haverford, Pa. 19041 USA
W- O -E 610-645-9208 (tel)
/ \ 610-348-4371 (mbl)
| 206-339-2515 (fax)
S
mailto:email@hidden
_______________________________________________
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.