How can I encode a character into Applescript or Script Debugger?

Here is example code that I need to submit via osascript:
osascript -e ‘set AppleScript’s text item delimiters to “:”’
However, the apostrophe in “AppleScript’s” messes up osascript.

I can write:
osascript -e ‘set AppleScript’\’‘s text item delimiters to “:”’
However, AppleScript will now baulk at the apostrophe backslash apostrophe apostrophe ‘’’ while trying to compile it without osascript.

Is there a way to encode the apostrophe, like a hex code \x27 or something else, that will allow both Applescript and osascript to compile?

PS. I know I can remove “Applescript’s” from “text item delimiters” and get the same result. My problem is more involved and I didn’t want to place all the code here. Just an example to present my problem.


I suppose this won’t work:

text item delimiters of AppleScript

I’m wondering where you’re getting the text with the smart quotes (AKA curly, typographer’s quotes)? Script Debugger, by default, uses dumb quotes (straight quotes).

Some applications allow an option-’ to force a straight quote.

“Applescript’s” is not my specific problem. It is just an example.

I need to know how to encode an apostrophe so that it will compile in Applescipt/Script Debugger and in an osascript enclosure.

However Ed, you did make me start thinking about other ways to reword my real problem code. Thank you.


#!/usr/bin/env bash

read -r -d '' dataStr <<'EOF'
set dataStr to "Now is the time for all good men to come to the aid of their country."
set AppleScript's text item delimiters to " "
return text items of dataStr

osascript -e "$dataStr"


I believe I can make that work for me. THANK YOU!


1 Like

just look at…
quoted form of “string’s”