[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: End-of-line characters in long strings
- From: Doug Rogers <rogers@...>
- Date: Fri, 18 Jan 2008 18:38:26 -0500
> I understand the convenience of normalizing end-of-lines for
> file:read("*l") and for Lua source code,...
I hate to drag out a discussion, but I want to make sure I understand this.
I happened to be coding up a script last night and notice that when I
combined lines which were read with '*l', they had a CR in the middle. I
was running under Linux but the input file was generated under Windows
so it had CR's in it. Here's a sample that shows what I mean:
> f:write('line 1\r\nline 2\r\n')
I was expecting the CR to be removed, though the manual doesn't say it
will be. It was easy enough to fix, if a little clunky.
My personal preference is that '*line' strip CR/LF/CR-LF since it is
obviously intended for line-oriented transactions. Same with f:lines().
But I can't think of any other times that I would want this behavior.
When loading source code the parser can treat any of CR/LF/CR-LF as
newline, but embedded long strings should not be modified.
It is probably worth mentioning in the manual whenever the input data
Innovative Concepts, Inc. www.innocon.com 703-893-2007 x220