FROM : Stéphane Sudre
DATE : Fri Jul 28 20:23:42 2006
On mercredi, juillet 26, 2006, at 10:11 PM, stephen joseph butler
wrote:
> 2006/7/26, Stéphane Sudre <<email_removed>>:
>> [...]
>>
>> Ok, I need to rephrase the question to use the proper terms.
>>
>> How can I save a string in a plist inside <string></string> tags so
>> that the string is saved with character escaping for the '\r' (and
>> probably '\n') characters?
>>
>> This is done automatically for the & character.
>
> Have you given this a test as is? For example, in F-Script (a sort of
> Objective-C scripting language) I tried this:
>
> dict1 := NSDictionary dictionaryWithObjects:{'this is\r a test\r',
> '\r\rthis is another test\r\r'} forKeys:{'a', 'b'}
> dict1 writeToFile:'/Users/foo/test.plist' atomically:true
>
> dict2 := NSDictionary
> dictionaryWithContentsOfFile:'/Users/foo/test.plist'
> dict2 objectForKey:'a'
> dict2 objectForKey:'b'
>
> Both printed out fine. If you take a look at the XML spec, it has this
> to say about whitespace:
>
> "An XML processor MUST always pass all characters in a document that
> are not markup through to the application. A validating XML processor
> MUST also inform the application which of these characters constitute
> white space appearing in element content."
>
> So how whitespace is handled is entirely up to the application, it is
> illegal for parsers to ignore it. Obviously, Apple has chosen to not
> ignore it.
I have no doubt Apple is following the guidelines. The fact is that I'm
looking at a workaround for a funny issue involving a CVS server, where
a '\r' is switched to '\n'.
DATE : Fri Jul 28 20:23:42 2006
On mercredi, juillet 26, 2006, at 10:11 PM, stephen joseph butler
wrote:
> 2006/7/26, Stéphane Sudre <<email_removed>>:
>> [...]
>>
>> Ok, I need to rephrase the question to use the proper terms.
>>
>> How can I save a string in a plist inside <string></string> tags so
>> that the string is saved with character escaping for the '\r' (and
>> probably '\n') characters?
>>
>> This is done automatically for the & character.
>
> Have you given this a test as is? For example, in F-Script (a sort of
> Objective-C scripting language) I tried this:
>
> dict1 := NSDictionary dictionaryWithObjects:{'this is\r a test\r',
> '\r\rthis is another test\r\r'} forKeys:{'a', 'b'}
> dict1 writeToFile:'/Users/foo/test.plist' atomically:true
>
> dict2 := NSDictionary
> dictionaryWithContentsOfFile:'/Users/foo/test.plist'
> dict2 objectForKey:'a'
> dict2 objectForKey:'b'
>
> Both printed out fine. If you take a look at the XML spec, it has this
> to say about whitespace:
>
> "An XML processor MUST always pass all characters in a document that
> are not markup through to the application. A validating XML processor
> MUST also inform the application which of these characters constitute
> white space appearing in element content."
>
> So how whitespace is handled is entirely up to the application, it is
> illegal for parsers to ignore it. Obviously, Apple has chosen to not
> ignore it.
I have no doubt Apple is following the guidelines. The fact is that I'm
looking at a workaround for a funny issue involving a CVS server, where
a '\r' is switched to '\n'.






Cocoa mail archive

