Re: Hex URL to string
Re: Hex URL to string
- Subject: Re: Hex URL to string
- From: Michelle Steiner <email@hidden>
- Date: Mon, 7 May 2001 16:12:17 -0700
On 5/7/01 12:48 PM, Ehsan Saffari <email@hidden> wrote:
>
I am trying to decode a hexadecimal URL
>
>
with Akua I tried this: (dechevronized)
>
set x to <<data url
>
6D61696C746F3A6170706C657363726970742D7573657273406C697374732E6170706C652E6
>
36F6D>>
>
encode x in string from hexadecimal--> returns incorrect result
>
>
I also tried:
>
>
set x to
>
"6D61696C746F3A6170706C657363726970742D7573657273406C697374732E6170706C652E
>
636F6D"
>
encode x in string from hexadecimal--> returns incorrect result
>
>
Is there any method to decode a hex url so I can get the correct result:
>
"mailto:email@hidden"
I think the problem may be in your hex string; When I run this script,
global hexchars
set hexchars to "0123456789ABCDEF"
set output to ""
set x to
"66D61696C746F3A6170706C657363726970742D7573657273406C697374732E6170706C652
E636F6D"
--set x to
"4142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F606162636465
666768696A6B6C6D6E6F707172737475767778797A7B7C7D7E7F"
set iterations to (count of x) - 1
repeat with loop from 1 to iterations by 2
set hexnum to characters loop thru (loop + 1) of x
set decimalnum to computevalue(item 2 of hexnum) + (computevalue(item 1
of hexnum) * 16)
set ASCIIchar to the ASCII character of decimalnum
set output to output & ASCIIchar
end repeat
output
to computevalue(inputchar)
return (offset of inputchar in hexchars) - 1
end computevalue
--> "fwq+F[6W67&sBWW6W'4s7G2JRJ6"
However, if i comment out your hex string and replace it with the one
commented out above...
--> "ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
And that's the correct result, showing that the script is accurate, but
your input is in error.
--Michelle
----------------------------------------------------------------------
| Michelle Steiner | We're not human beings having a spiritual |
| | experience. We're spiritual beings |
| email@hidden | having a human experience. |
----------------------------------------------------------------------