What is the best way to iterate over string chars?

Adam D. Ruppe destructionator at gmail.com
Thu Feb 6 10:51:49 PST 2014


On Thursday, 6 February 2014 at 18:50:28 UTC, Cooler wrote:
> Example3:
> foreach(i, c; s){
>   // do something with c and i
> }

this is the best. You can also specific c to be char or wchar or 
dchar specifically if you want it do do some UTF decoding for 
you. (char is the default - note that this will send you each 
byte of a multi-byte sequence. dchar on the other hand will 
automatically combine those)


More information about the Digitalmars-d-learn mailing list