Martin DeMello
9/2/2007 8:17:00 PM
On 9/2/07, Xavier Noria <fxn@hashref.com> wrote:
> On Sep 1, 2007, at 1:16 PM, Martin DeMello wrote:
>
> > Is there any built-in way to force File.puts to use dos line endings,
> > regardless of the platform under which the program is running?
>
> If I undertand correctly what you want your program is going to
> explicitly output pairs "\r\n".
>
> If that's the case, in addition to the recommendation about IO#print
> already given take into account that the io needs binmode. Otherwise,
> on CRLF platforms you'd end up with "\r\r\n" on disk, which would be
> wrong. That's because the single "\n" in "\r\n" gives itself a pair
> "\r\n" in text mode. So IO#print CRLF in binmode is the complete
> portable solution.
Good point. As of now this will only ever be run on a linux box, but
it certainly doesn't hurt to future-proof it.
martin