A Line Break Is a Line Break
A line break is a line break is a line break, except when it’s not. Surprisingly, there are three different types of line breaks in the modern computing world, and OS X uses two of the three.
One might think the innocent line break, that docile whitespace that tells us when paragraphs begin and end, would be a relatively simple piece of computer engineering. Unfortunately, there’s more to the line break than meets the eye.
There are three different types of line breaks, all originally unique
to the major
operating systems: Windows/DOS, Macintosh,
and Unix. A document using Mac line breaks would look horrid on a
Windows system, and a document using Windows line breaks on Unix also
wouldn’t be interpreted correctly. The cause for
this is how the line break is actually created. The Mac, by default,
uses a single
carriage return
(<CR>), represented as
\r. Unix, on the other hand, uses a single
linefeed (<LF>), \n.
Windows goes one step further and uses both, creating a
(<CRLF>) combination,
\r\n.
To make matters still more interesting, until OS X came along, OS-specific line breaks stayed in their own environment and didn’t play nicely with others. Windows understood only its brethren, Unix cackled madly at anything else, and the Mac just grinned knowingly. OS X, however, understands both the original Mac line break and Unix line breaks.
This can cause confusion very easily, especially considering that most Mac applications (i.e., most anything ...