Jonathan M Davis:
> You should pretty much never deal with each individual char or wchar in a 
> string 
> or wstring. Do the conversion to dchar or dstring if you want to access 
> individual characters. You can also use std.utf.stride() to iterate over to 
> the 
> next code unit which starts a code point, but you're still going to have to 
> make 
> sure that you convert it to a dchar to process it properly. Otherwise, only 
> ASCII characters will work right (since they fit in a single code unit). 
> Fortunately, foreach takes care of all this for is if we specify the element 
> type as dchar.

I am starting to think that for safety the foreach on a string has to yield 
dchars on default, and to yield chars only on request:
foreach(c; "hello") => dchars
foreach(char c; "hello") => chars

Bye,
bearophile

Reply via email to