Using lazy code to process large files

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 2 10:37:09 PDT 2017


On 8/2/17 1:16 PM, kdevel wrote:
> On Wednesday, 2 August 2017 at 15:52:13 UTC, Steven Schveighoffer wrote:
> 
>> If we use the correct code unit sequence (0xc3 0x9c), then [...]
> 
> If I avoid std.string.stripLeft and use std.algorithm.stripLeft(' ') 
> instead it works as expected:

What is expected? What I see on the screen when I run my code is:

[Ü]

What I see when I run your "working" code is:

[?]

You are missing the point that your input string is invalid.

std.algorithm is not validating the entire string, and so it doesn't 
throw an error like string.stripLeft does. writeln doesn't do any 
decoding of individual strings. It avoids the problem and just copies 
your bad data directly.

If you fix the input, both will work correctly.

-Steve


More information about the Digitalmars-d-learn mailing list