std.string inPattern() and UTF symbols

Fra Fra at b.it
Mon Dec 9 09:12:41 PST 2013


On Monday, 9 December 2013 at 16:10:34 UTC, qznc wrote:
> That is probably not the root of Fras problem, though.

You are right, that was not the root, even if the mistake is 
extremely simple: foreach(c, s) is used to seek the string.
I just realized that foreach can mess things up when used on 
strings. I can't scroll the feeling this is a pitfall of the 
language:

the code
foreach (immutable dchar c; s)
         writeln("token: ", c);

produces deeply different results than
foreach (c; s)
         writeln("token: ", c);

see http://dpaste.dzfl.pl/302291fd
I understand why foreach would produce such a result, but I guess 
newcomers will get burnt by this.
I will open a bug report for the munch function in the mean time.


More information about the Digitalmars-d-learn mailing list