Why the hell doesn't foreach decode strings

so so at so.so
Fri Oct 21 00:24:35 PDT 2011


On Thu, 20 Oct 2011 22:37:56 +0300, Martin Nowak <dawg at dawgfoto.de> wrote:

> It just took me over one hour to find out the unthinkable.
> foreach(c; str) will deduce c to immutable(char) and doesn't care about  
> unicode.
> Now there is so many unicode transcoding happening in the language that  
> it starts to get annoying,
> but the most basic string iteration doesn't support it by default?

I really can't believe why people expect that.
By definition string is an array of chars, and this way it is consistent.
All we need is:

foreach(c, whatever(str))

instead of:

foreach(c, str)


More information about the Digitalmars-d mailing list