在 AppleScript 字符串中使用引号 [英] Using quotes in a AppleScript string

查看:31
本文介绍了在 AppleScript 字符串中使用引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆