[Macpartners] Re: What is the Mac OS X "standard" line ending?
Mateja Miljacki
mateja at apple.com
Wed Oct 26 13:53:02 EDT 2005
I don't think we've ever made an official statement on this but IMHO
the most common line ending is line-feed these days, however a well
written program has to be prepared to cope with files with a variety
of different line endings on input.
Instead of Line ending, think UNICODE
I will poke around and see if we have any definitive statement (but I
doubt it.) The Unix tradition is linefeed and most current programs
on OS X seem to work that way.
Just to keep everyone on their toes, Unicode actually defines six
different sequences that should all mean "end of line". According to
wikipedia ... http://en.wikipedia.org/wiki/CRLF#Unicode
Unicode
The Unicode standard addresses the problem by defining a large number
of characters that conforming applications should recognize as line
terminators:
LF: Line Feed, u000A
CR: Carriage Return, u000D
CR+LF: CR followed by LF
NEL: Next Line, u0085
FF: Form Feed, u000C
LS: Line Separator, u2028
PS: Paragraph Separator, u2029
This may seem overly complicated compared to a simple approach like
converting all line terminators to a single character, for example
LF. The simple approach breaks down, however, when trying to convert
a text file from an encoding like EBCDIC to Unicode and back. When
converting to Unicode, NEL would have to be replaced by LF, but when
converting back it would be impossible to decide if a LF should be
mapped to an EBCDIC LF or NEL. The approach taken in the Unicode
standard allows this transformation to be information preserving
while still enabling applications to recognize all possible types of
line terminators.
On Oct 26, 2005, at 11:50 AM, David M Rosenberg wrote:
> Is there a clear direction in which Apple is heading with respect to
> line endings in text files?
>
> I know that some programs can deal with either Mac OS 9 line endings
> (a single Carriage-Return character), Unix line endings (a single
> Line-Feed character), or DOS line endings (a Carriage-Return +
> Line-Feed pair). I also know that other programs give you the option
> of generating files with the user's choice of line endings.
>
> My question is: What does Apple consider to the "standard" line
> endings to be used in a text file written by a Mac OS X program in a
> circumstance where you can't ask the user to choose?
>
> I would be especially appreciative to have a pointer to an official
> Apple statement to the effect that: "In Mac OS X the 'standard line
> ending' is ...."
>
> --
> /David M Rosenberg <rosenberg at mit.edu> 1-617-253-8054
> MIT / IS&T / Admin Computing / Technical Services
>
--
Mateja Miljacki
mateja at apple.com
Systems Engineer
o: 617-718-9955
AppleCare Support
http://search.apple.com/
Apple Science
http://www.apple.com/science/
Technical Resources for Integrating Mac OS X
http://www.apple.com/education/technicalresources/
--
More information about the Macpartners
mailing list