문제

특히 CSSEDIT 용 AutoCompletion.plist 파일을 편집하고 있습니다 (중요하다면).

내 질문은, 탈출 해야하는 문자열 요소를 가진 문자가 있습니까? 공간? 인용 부호?

편집 : 명확하게 말하면 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는 파일을 편집 할 때 HAYWIRE가됩니다.

도움이 되었습니까?

해결책

If you're editing an XML plist using a text editor of some sort, you'll need to escape characters just like in any XML. The basic characters to watch out for are:

< (less than), escaped as &lt;

> (greater than), escaped as &gt;

& (ampersand), escaped as &amp;

' (apostraphe), escaped as &apos;

" (quote mark), escaped as &quot;

So in your example, you would want

<string>Georgia, Times, &apos;Times New Roman&apos;, serif</string>

You can also use a tool such as Apple's Property List Editor, which is included with their free Xcode developer tools, or a third party product like PlistEdit Pro, both of which will take care of all the character escaping for you.

다른 팁

You can use plutil to check the syntax of your plists. (Note that this won't validate whether the application will understand what you've done to its plist...)

There are 3 types of plists, and the escaping rules depend on type you are working with. The most common form are XML plists, which do require certain things to be escaped. In general you can use XML escaping rules within the string elements. If you are working with older NextStep style plists I believe much less needs to be escaped, but I would need to look up the details to be certain of what the rules are. The third type are binary, I am pretty confident you are not editing those with CSSEdit.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top