特别是,我正在为 CSSEdit 编辑 AutoCompletion.plist 文件(如果这很重要的话)。
我的问题是,是否有任何包含 STRING 元素的字符需要转义?空间?引号?
编辑: 需要说明的是,我没有使用 CSSEdit 来编辑文件——而是该文件是 CSSEdit 包的一部分。我正在使用 TextMate 编辑文件(尽管“Property List Editor.app”是另一个选项)并且它是 XML 格式的。以下是 AutoCompletion.plist 文件的片段:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>font-family</key>
<array>
<string>Arial</string>
<string>Helvetica</string>
<string>Georgia</string>
<string>serif</string>
<string>sans-serif</string>
<string>cursive</string>
etc...
我想添加带有空格和单引号的字符串,例如:
<string>Georgia, Times, 'Times New Roman', serif</string>
但是当我这样编辑文件时,CSSEdit 变得乱七八糟
最佳答案
如果您正在使用某种文本编辑器编辑 XML plist,则需要像在任何 XML 中一样对字符进行转义。需要注意的基本字符是:
<(小于),转义为 <
>(大于),转义为 >
&(& 符号),转义为 &
'(撇号),转义为 '
"(引号),转义为 "
所以在你的例子中,你会想要
<string>Georgia, Times, 'Times New Roman', serif</string>
您还可以使用 Apple 的 Property List Editor 等工具,它包含在他们的免费 Xcode developer tools 中。 ,或第三方产品,如 PlistEdit Pro ,这两者都会为你处理所有转义的角色。
关于xml - 编辑 .plist 文件 - 是否允许单引号作为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/256554/