Using lazy code to process large files

kdevel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 2 10:16:07 PDT 2017


On Wednesday, 2 August 2017 at 15:52:13 UTC, Steven Schveighoffer 
wrote:

[...]

> First, as a tip, please post either a link to a paste site, or 
> don't put the line numbers. It's much easier to copy-paste your 
> code into an editor if you don't have the line numbers.

With pleasure.

[...]

> 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:

void main ()
{
    import std.stdio;
    import std.utf;
    import std.algorithm;

    string [] src = [ " \xfc" ]; // blank + latin-1 encoded u 
umlaut
    auto result = src
       .map!(a => a.byCodeUnit)
       .map!(a => a.stripLeft(' '));
    result.writeln;
}




More information about the Digitalmars-d-learn mailing list