Re: Encode URLs for posting help
Re: Encode URLs for posting help
- Subject: Re: Encode URLs for posting help
- From: Christopher Biagini <email@hidden>
- Date: Thu, 31 Mar 2005 00:04:29 -0500
On Mar 30, 2005, at 11:53 PM, Neil Lee wrote:
Is there a way in Applescript to properly encode the URL for HTTP
posting?
Here's my personal favorite, from
<http://www.apple.com/applescript/scripteditor/12.html>.
-- this sub-routine is used to encode text
on encode_url(this_text)
set the acceptable_characters to
"abcdefghijklmnopqrstuvwxyz0123456789_"
set the encoded_text to ""
set the character_list to {}
repeat with this_char in this_text
set this_char to the contents of this_char
if this_char is in the acceptable_characters then
set the end of the character_list to this_char
else
set the end of the character_list to
encode_char(this_char)
end if
end repeat
set text item delimiters to ""
return (the character_list) as string
end encode_url
-- this sub-routine is used to encode a character
on encode_char(this_char)
set the ASCII_num to (the ASCII number this_char)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7",
"8", "9", "A", "B", "C", "D", "E", "F"}
set x to item ((ASCII_num div 16) + 1) of the hex_list
set y to item ((ASCII_num mod 16) + 1) of the hex_list
return ("%" & x & y) as string
end encode_char
--Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden