Using lazy code to process large files

kdevel via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 2 08:02:22 PDT 2017


On Wednesday, 2 August 2017 at 13:45:01 UTC, Steven Schveighoffer 
wrote:
> As Daniel said, using byCodeUnit will help.

stripLeft seems to autodecode even when fed with CodeUnits. How 
do I prevent this?

       1 void main ()
       2 {
       3    import std.stdio;
       4    import std.string;
       5    import std.conv;
       6    import std.utf;
       7    import std.algorithm;
       8
       9    string [] src = [ " \xfc" ]; // blank + latin-1 
encoded u umlaut
      10    auto result = src
      11       .map!(a => a.byCodeUnit)
      12       .map!(a => a.stripLeft);
      13    result.writeln;
      14 }

Crashes with a C++-like dump.



More information about the Digitalmars-d-learn mailing list