On Tuesday, 4 November 2014 at 18:09:48 UTC, Ivan Kazmenko wrote:
On Monday, 3 November 2014 at 20:10:02 UTC, Gary Willoughby
wrote:
On Monday, 3 November 2014 at 19:47:17 UTC, Ivan Kazmenko
wrote:
So, if there is an idiomatic way to read the whole file into
a string which is Unicode-compatible, it would be great to
learn that, too.
Maybe something like this:
import std.stdio;
import std.array;
import std.conv;
string text = stdin
.byLine(KeepTerminator.yes)
.join()
.to!(string);
And thanks for a short alternative!
At first glance, looks like it sacrifices a bit of efficiency
on the way: the "remove-line-breaks, then add-line-breaks" path
looks redundant.
Still, it does not store intermediate splitted representation,
so the inefficiency is in fact not catastrophic, right?
And sorry, I didn't read that correctly.
Using byLine with KeepTerminator.yes and join with nothing, it
does not alter line breaks at all.
So, the efficiency of this is entirely up to whether optimizer is
able to detect that the break/join sequence is a operation.