Create link to line?

Though potentially less efficient than a pure vanilla AppleScript solution, this may be a more secure means of URL encoding in the long run, using ASObjC:

use framework "Foundation"

on encodeForURL(theText)
	set nsInput to current application's NSString's stringWithString:theText
	set characterSet to current application's NSCharacterSet's URLQueryAllowedCharacterSet()
	return (nsInput's stringByAddingPercentEncodingWithAllowedCharacters:characterSet) as text
end encodeForURL

I believe this comes originally from Shane Stanley, though I don’t remember where I copied it from.

1 Like