Re: URL Encoding With Pure AppleScript
Re: URL Encoding With Pure AppleScript
- Subject: Re: URL Encoding With Pure AppleScript
- From: Emmanuel LEVY <email@hidden>
- Date: Wed, 10 Jul 2013 15:10:27 +0200
This is great code and a great page.
Also, you may want to have a look at Satimage.osax's dictionary and its escapeURL command.
Best,
Emmanuel
On Jul 10, 2013, at 9:00 AM, Kaydell Leavitt wrote:
> 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.
>>>
>>> -- Kaydell
>>> email@hidden
>>> http://learnbymac.com
>>>
>>> _______________________________________________
>>> 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
>>
>> _______________________________________________
>> 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
>
> _______________________________________________
> 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
_______________________________________________
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