• 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: Encode URLs for posting help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Encode URLs for posting help (From: Neil Lee <email@hidden>)

  • Prev by Date: Encode URLs for posting help
  • Next by Date: Re: Encode URLs for posting help
  • Previous by thread: Encode URLs for posting help
  • Next by thread: Re: Encode URLs for posting help
  • Index(es):
    • Date
    • Thread