in reply to maintaining newlines in file

I'll tell you, as a user of editors, I don't want my newlines changed. I run Linux and when I edit a windows file, I'm doing it for a good reason and I want the new newlines to be the same as the newlines that were there when I opened the file. Which is what happens with both emacs and gedit. If that's not what happens, I look for a new editor.

As far as detecting the value of \n, I think you're trying too hard not to reinvent the wheel. Deciding which of the 3 endings a file uses is, imho, a job for a regex, not a module.

Personally, I've never encountered a file where mixed newline types would be anything be a corrupt file. For fun, I'll imagine printing a file for a win client out of a mod_perl module that runs on linux. Well, the windows EOL would be contained in quotes and/or escaped so the obvious *NIX dominance should prevail. Of course, I could be missing an important use case here.

That said, an option to convert EOL to various formats would be a nice option to offer.

Replies are listed 'Best First'.
Re^2: maintaining newlines in file
by ddn123456 (Pilgrim) on Aug 25, 2008 at 10:47 UTC
    Hi rowdog,

    Indeed any application called "editor" ought to convert eol's only on demand.

    FYI I did once encounter a CA Unicenter Software Delivery command line output on win32 where a sole \r was used and required in the middle of a specific line. Win32 interpreted it as a "space" and the application really needed it as such for I/O. :-( Officially it worked as designed due to its crossplatformness :p .

    Greetings
    ddn123456