AppleScript Library

URL Library

   Two simple handlers to decode and encode URLs. The urlEncode handler is also very useful for creating AppleScript URLs as found throughout this site.

All handlers displayed on this page were freely available on the internet or written by myself. Please refer to the copyright section at the end of this page. Feedback appreciated.


AppleScript Editor open download

Properties
myName
Encode/Decode
urlEncode
urlDecode

Properties

property myName

Name that should be used when loading this library.

show source AppleScript-Editor open insert append toc
property myName : "_url"

Encode/Decode

urlEncode(str)

URL encode the passed string.

strstring
string

Man pages:  echo, perl

Written by:ljr

Example:

urlEncode("Nürnberg $%@") 
--> "N%C3%BCrnberg%20%24%25%40"
show source AppleScript Editor open insert append toc
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

urlDecode(str)

URL decode the passed string.

strstring
string

Man pages:  echo, perl

Written by:ljr

Example:

urlDecode("N%C3%BCrnberg%20%24%25%40") 
--> "Nürnberg $%@"
show source AppleScript Editor open insert append toc
on urlDecode(str)
	local str
	try
		return (do shell script "/bin/echo " & quoted form of str & ¬
			" | perl -MURI::Escape -lne 'print uri_unescape($_)'")
	on error eMsg number eNum
		error "Can't urlDecode: " & eMsg number eNum
	end try
end urlDecode

Copyright

© 2008 ljr (http://applescript.bratis-lover.net)
urlEncode, urlDecode

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.