Benches / macOS
4
URLencode in AppleScript
apple Verified ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Does anyone know if there is a URLencode function available in AppleScript?
4 replies
Sign in or join Beachball Help to reply.
0
red_menace ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
There isn't one in AppleScript per se, but you can call a Python routine that will do it (refer to the
pydoc manual page for more information):
do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of TheTextToEncode
0
thompsonsol ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Thanks. I'll give it a try.
Do you need Python to be installed or does it come standard?
0
red_menace ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Several scripting languages are already installed, including Python.
0
TomkOx ·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Another way (via PHP):
AppleScript:
*set input to "Text or URL to encode via PHP!"*
*set textencoded to do shell script "php -r 'echo trim(urlencode(" & """ & input & "" & ""));'"*