在AppleScript字符串中使用引号 [英] Using quotes in a AppleScript string
问题描述
我正在使用AppleScript,需要这样做:
I am working with AppleScript and need to do this:
set TextToWrite to " #!/bin/bash cd "$( dirname "$0" )" java -server -Xmx4G -jar ./craftbukkit.jar" "
如您所见,我需要在字符串中加上引号.我该如何设置
As you can see, the text I need to make into a string has quotes in it. How do I set
#!/bin/bash cd "$( dirname "$0" )" java -server -Xmx4G -jar ./craftbukkit.jar"
到没有引号弄乱的AppleScript字符串?
to an AppleScript string without the quotes messing it up?
推荐答案
要将文字引号插入Applescript字符串中,您必须对它们进行转义,即
To insert literal quotes into an Applescript string, you have to escape them, i.e.
set myString to "This is a \"quoted\" text."
AppleScript与大多数语言具有相同的约定,即使用反斜杠转义特殊字符,其中只有两个:引号和…反斜杠.请参阅 AppleScript语言指南的特殊字符串字符"部分.
AppleScript has the same convention as most languages, which is to use a backslash for escaping of special characters, of which there are only two: quotes and … backslash. See the section "Special string characters" of the AppleScript Language Guide.
这篇关于在AppleScript字符串中使用引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!