• 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: URL Encoding With Pure AppleScript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: URL Encoding With Pure AppleScript


  • Subject: Re: URL Encoding With Pure AppleScript
  • From: Kaydell Leavitt <email@hidden>
  • Date: Wed, 10 Jul 2013 01:00:03 -0600

Hello,

Sorry, here is the URL to the new code:

http://www.learnbymac.com/wiki/index.php?title=URI_Encoding


-- Kaydell
email@hidden
http://learnbymac.com




On Jul 10, 2013, at 12:45 AM, Kaydell Leavitt <email@hidden> wrote:

Hello AppleScripters,

I previously posted to the wrong thread.  I'm sorry.  I mean to start this new thread.

I've developed a urlEncode() handler written completely in AppleScript.  

The one that called perl worked and this new one works too.

I guess that I'll go with the pure AppleScript solution provided that it is OK.

-- Kaydell
email@hidden
http://learnbymac.com




On Jul 9, 2013, at 11:49 PM, Kaydell Leavitt <email@hidden> wrote:

I went looking for a urlEncode script that I could call from AppleScript and found this handler called urlEncode()
I believe that it may work OK, but I would like to understand what's going on better than I do.  .

-- This script uses the perl command from the shell to do a URL Encoding
-- This script is from the following website: http://applescript.bratis-lover.net/library/url/
on urlEncode(str)
local str
try
return (do shell script "/bin/echo " & quoted form of str & " | perl -MURI::Escape -lne 'print uri_escape($_)'")
on error eMsg number eNum
error "Can't urlEncode: " & eMsg number eNum
end try
end urlEncode

-- Does this make sense?  The id of the character is only 233 but the percent-encoding makes it look
-- like the accented é takes two bytes to encode.
-- Does it have anything to do with whether the character encoded here is UTF-8, UCS-2, UTF-16, or UTF-32?
set this_character to "é"
set this_encoding to urlEncode(this_character)
set this_id to id of (this_character)
display dialog "The character: " & this_character & " is percent-encoded with: " & this_encoding & " and it's id is: " & this_id

I understand that ASCII has  been deprecated from AppleScript and that nowadays that everything is Unicode text = text = string, but I believe that what's different is UTF-8 which is what I want.

Each of the following expressions returns 233:

id of ("é" as string)
id of ("é" as text)
id of ("é" as Unicode text)
id of ("é" as «class utf8»)

I read that nowadays instead of calling ASCII number that we are supposed to use "id of" instead.

I would like to develop my own urlEncode() handler in pure AppleScript so that I can understand how.  I've googled and found some that don't really work for UTF-8 because they assume that all characters are 8-bits wide.

Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users This email sent to email@hidden
  • Follow-Ups:
    • Re: URL Encoding With Pure AppleScript
      • From: Alex Zavatone <email@hidden>
    • Re: URL Encoding With Pure AppleScript
      • From: Emmanuel LEVY <email@hidden>
References: 
 >AppleScript fails in Automator - Permissions error (From: Lists <email@hidden>)
 >Re: AppleScript fails in Automator - Permissions error (From: "Manoah F. Adams" <email@hidden>)
 >Re: AppleScript fails in Automator - Permissions error (From: Lists <email@hidden>)
 >Re: AppleScript fails in Automator - Permissions error (From: Kaydell Leavitt <email@hidden>)
 >Re: AppleScript fails in Automator - Permissions error (From: Lists <email@hidden>)
 >Re: AppleScript fails in Automator - Permissions error (From: Kaydell Leavitt <email@hidden>)
 >URL Encoding With Pure AppleScript (From: Kaydell Leavitt <email@hidden>)

  • Prev by Date: URL Encoding With Pure AppleScript
  • Next by Date: Re: URL Encoding With Pure AppleScript
  • Previous by thread: URL Encoding With Pure AppleScript
  • Next by thread: Re: URL Encoding With Pure AppleScript
  • Index(es):
    • Date
    • Thread