http://d.puremagic.com/issues/show_bug.cgi?id=5378

           Summary: File.byLine terminator string
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2010-12-26 07:11:51 PST ---
This is the signature of File.byLine:

ByLine!(Char,Terminator) byLine(Terminator = char, Char = char)
(KeepTerminator keepTerminator = KeepTerminator.no, Terminator terminator =
'\x0a'); 

But on Windows the line terminators are 2 chars long (CR+LF), see:
http://en.wikipedia.org/wiki/Newline#Representations

So I think the second argument of argument byLine() needs to be a string.

This is code I expected to use, that currently is not accepted:

import std.stdio;
void main() {
    auto lines = File("test.txt").byLine(File.KeepTerminator.no, "\r\n");
}

----------------

After that bug report, a little enhancement request: generally on Windows I
usually open files with Windows-style line terminators, while on Linux I open
files with Unix-style line terminators, so if possible a better default for the
second argument of byLine() is a string constant that changes according to the
operating system.

----------------

A workaround is to open the file in text mode, but I don't know if this works
well if you want to open a Windows-style file on Linux:


import std.stdio;
void main() {
    auto lines = File("test.txt", "r").byLine();
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to