On Aug 13, 2007, at 5:36 PM, dda wrote:

> Actually, depending on what text editor you are using, on Mac OS X,
> ASCII(13) may still be used.

And no matter what, most editors let the user configure the  
convention to any of those three. That's why there's a difference  
between _portable_ line-oriented programs and _robust_ line-oriented  
programs.

A portable line-oriented program is a one that works fine on the  
assumption that the line-ending convention is the one of the runtime  
platform. A log analysis tool may be written like that for example.  
Programming languages provide idioms to do this very easily.

A robust line-oriented program tries to understand every convention.  
For instance a CGI processing a text area. That normally requires  
newline normalization by hand. Some programming languages offer I/O  
options to understand everything on reading. For instance the :crlf  
Perl I/O layer, or the universal line-ending mode in Python. I am not  
aware of any such trick on Ruby, in that case a simple regexp may  
suffice.

Writing is a different story, because the program itself is the one  
using some convention. The way to choose it depends on its own logic.

-- fxn