[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Windows query
- From: Jonathan Goble <jcgoble3@...>
- Date: Fri, 29 Jan 2016 02:10:56 -0500
On Fri, Jan 29, 2016 at 1:53 AM, Paul Merrell <firstname.lastname@example.org> wrote:
> I don't know the answer to that question, Dirk, but my understanding
> is that "\r" is unnecessary on any of Linux/Unix, Windows, or the
> recent releases of OS X. I write and share lots of multi-OS scripts
> for NoteCase Pro and stopped including the carriage return token years
> ago without any subsequent complaint from any users (regarding the
> missing "\r").
Windows Notepad, even in Windows 10, expects "\r\n" and only "\r\n"
for line endings. Attempting to open a text file with just "\n" line
endings in Notepad will result in the whole file being displayed on a
single line, with the "\n" characters simply stripped out.
That said, Lua will, when passed a "\n", automatically translate that
to "\r\n" when running on Windows and writing to a file opened in text
mode (without the "b" flag in the mode argument to io.open), so as
long as you don't open the file in binary mode, you can just write
"\n" and it becomes platform-independent. On the other hand, if you
want full control over exactly what line ending(s) you use, then
binary mode is the way to go, since it will write exactly what you
pass to it.