access foreach index counter for Iterate n times
mw
mingwu at gmail.com
Sat May 21 17:07:41 UTC 2022
On Saturday, 21 May 2022 at 16:11:50 UTC, Adam D Ruppe wrote:
> On Saturday, 21 May 2022 at 15:43:59 UTC, mw wrote:
>> Same question:
>> Why 3 bytes? Not 4 bytes?
>
> Same answer: it is pointing at the character in the ORIGINAL
> ARRAY. The original array is NOT made out of dchars but it
> reads and converts on the fly while maintaining the correct
> position.
UTF variable-length encoding is the answer I'm looking for.
> See that's the beauty of it: how it gets there can be pretty
> complicated (especially when going backwards with
> foreach_reverse), but it always gives the right answer.
OK, it's a loop array index, not a "loop counter"; so most of
time these two things are the same, but in this special case of
UTF variable-length encoding they are different.
two comments:
1) can we also have a true "loop counter"? coming from a numeric
computation application background, "loop counter" certainly is
very useful.
2) can we also make it work for range? i.e. the question in my
original 1st post.
More information about the Digitalmars-d
mailing list