Re: Question about line breaks and file types
Re: Question about line breaks and file types
- Subject: Re: Question about line breaks and file types
- From: Douglas Davidson <email@hidden>
- Date: Mon, 4 Aug 2003 17:17:59 -0700
On Monday, August 4, 2003, at 04:49 PM, Dustin Voss wrote:
On Sunday, August 3, 2003, at 10:19 PM, Francisco Tolmasky wrote:
Is there a necessary connection between line breaks and file types.
For example, should a unicode text file use unicode line breaks. I
ask this because programs like BBEdit let you change the line break
style on the fly, seemingly without changing the file type.
In simple text files, there is no connection. BBEdit replaces all line
breaks with the type you specify. In RTF files, there might be a
specified line break character.
RTF has its own ways of specifying breaks. You should not need to
worry about this unless you are implementing your own RTF reader or
writer, rather than using the ones built in to Cocoa.
The Unicode Consortium has recommendations on the subject of line
breaks. It is in Unicode 4.0, but I don't have a copy. It probably has
not changed since http://www.unicode.org/reports/tr13/tr13-9.html:
* If you know the line break is being used to separate paragraphs,
replace it with U+2029 (Paragraph Separator).
* If you know the line break is being used to separate lines, replace
it with U+2028 (Line Separator).
* If you don't know, replace it with your platform's line break
character ('\n'). This will be 0x0D or 0x0A. I know it was 0x0D in
Classic, but I think Unixes use 0x0A. Just use '\n', though.
The practical prescription would be to consider the likely readers of
your data. If you wish to use Unix tools on it, you will want to use
\n. If you wish to pass it to Classic apps, \r might be more
convenient.
Unfortunately, as I stated in another message, Cocoa might not
consider U+2028 or U+2029 to be line breaks. They aren't in
[NSCharacterSet whitespaceAndNewlineCharacterSet], anyway.
The Cocoa text system recognizes both.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.