access foreach index counter for Iterate n times

H. S. Teoh hsteoh at quickfur.ath.cx
Sat May 21 15:52:10 UTC 2022


On Sat, May 21, 2022 at 03:43:59PM +0000, mw via Digitalmars-d wrote:
> On Saturday, 21 May 2022 at 15:23:08 UTC, Adam D Ruppe wrote:
> > On Saturday, 21 May 2022 at 15:06:31 UTC, mw wrote:
> > > > It isn't a loop counter. It is an index back into the original
> > > > source. Consider:
> > > 
> > > 1) First, why not 0 then 4? Since dchar is 32 bits.
> > 
> > It is an index back into the *original source* given to foreach.
> > 
> > I gave it a char[], not a dchar[]. So it is counting chars in that
> > original char[].
> > 
> 
> Same question:
> 
> 
> Why 3 bytes? Not 4 bytes?
[...]

Because UTF-8 is a variable-length encoding.


T

-- 
Life is too short to run proprietary software. -- Bdale Garbee


More information about the Digitalmars-d mailing list