Splitting up large dirty file

Dennis dkorpel at gmail.com
Thu May 17 20:08:09 UTC 2018

On Wednesday, 16 May 2018 at 15:47:29 UTC, Jon Degenhardt wrote:
> If you write it in the style of my earlier example and use 
> counters and if-tests it will work. byLine by itself won't try 
> to interpret the characters (won't auto-decode them), so it 
> won't trigger an exception if there are invalid utf-8 
> characters.

When printing to stdout it seems to skip any validation, but 
writing to a file does give an exception:

     auto inputStream = (args.length < 2 || args[1] == "-") ? 
stdin : args[1].File;
	auto outputFile = new File("output.txt");
     foreach (line; inputStream.byLine(KeepTerminator.yes)) 
std.exception.ErrnoException at C:\D\dmd2\windows\bin\..\..\src\phobos\std\stdio.d(2877):  (No error)

According to the documentation, byLine can throw an UTFException 
so relying on the fact that it doesn't in some cases doesn't seem 
like a good idea.

More information about the Digitalmars-d-learn mailing list