Re: How would you convert a \r to its UTF-8 counterpart ?
Re: How would you convert a \r to its UTF-8 counterpart ?
- Subject: Re: How would you convert a \r to its UTF-8 counterpart ?
- From: Ricky Sharp <email@hidden>
- Date: Tue, 25 Jul 2006 16:39:46 -0500
On Jul 25, 2006, at 4:20 PM, Stéphane Sudre wrote:
Let's say I want to save the following string in a .plist file:
"this is a stupid line of text, isn't it?\r"
and the resulting .plist shall be something like this:
<I don't remember the plist header so this is a replacement>
<dict>
<key>A string</key>
<string> this is a stupid line of text, isn't it?
</string>
</dict>
</I should remember them though>
The idea being to have the \r character be replaced by its hexa value.
If I save a NSDictionary using the writeToFile:atomically: API, I
will get a '\r'.
If I replace the \r with 
, I will get &#x0D; of course.
Any idea on how to do this?
I think this is a bit tricky since in the XML spec, any whitespace at
the beginning or end of a tag's value can be automatically stripped
out. Whether or not these rules apply to a .plist is beyond me.
Also because writeToFile:atomically: actually writes out the bytes to
the file, you have no control over the contents of a tag. Thus, I
think you'll need to use the character entity encoding like you're
doing (i.e. 
). When reading things back in, replace any
character entities with appropriate values.
If you had control over the contents of a tag, you could potentially
wrap it in a CDATA clause. I believe leading/trailing whitespace
would not get removed.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden