Click to See Complete Forum and Search --> : [RESOLVED] Line Endings (not a PHP question, but I figure you should know, maybe?)


Kyleva2204
10-17-2008, 08:54 PM
I have some code I need to be viewable on multiple platforms (Windows, Unix, Linux, etc). Currently, my line endings were set to LF. However, Windows failed at reading LF line endings.. I tried CRLF, and that worked on both Windows and TextMate on Mac. I'm not sure if TextMate is just fluent in more than one line ending, or if Mac OS can really read them fine. So which should I use? What are some other ones?

Thanks

NogDog
10-17-2008, 09:07 PM
Generally, the only reasonably current editor I know of that does not deal with just a LF is Windows Notepad (which is still stuck in the days of teletype printers needing both a carriage return and a line feed to return the print head to the left side and move the paper up 1 line :rolleyes: ). For maximum portability, I'd generally recommend just using the LF and add a note somewhere that Windows users should open it with Wordpad instead of Notepad.

felgall
10-17-2008, 09:09 PM
Mac OS9 and earlier - \r
Windows - \r\n
Linux and Mac OS/x - \n

You can use a regular expression in your preferred language to match any combination and then convert to what you require.

/\r|\n|\r\n/

Kyleva2204
10-17-2008, 09:22 PM
Generally, the only reasonably current editor I know of that does not deal with just a LF is Windows Notepad (which is still stuck in the days of teletype printers needing both a carriage return and a line feed to return the print head to the left side and move the paper up 1 line :rolleyes: ). For maximum portability, I'd generally recommend just using the LF and add a note somewhere that Windows users should open it with Wordpad instead of Notepad.

Thanks NogDog :).