Program:
```d
import std.stdio;

void main() {
    string s = "ταυ";
    foreach(i, elem; s) {
        writefln("%s %s '%s'", i, cast(int)elem, elem);
        writefln("%s", elem);
    }
}

```
Output:
```
0 207 '�'

1 132 '�'
τ
2 206 '�'

3 177 '�'
α
4 207 '�'

5 133 '�'
υ
```
How does the second writefln know about the context and can adequately output a character on every other iteration?

However, if you do it this way (see below), the output is very strange with arbitrary line breaks.
```d
    foreach(i, elem; s) {
        writefln("'%s', %s", elem, elem);
    }
```

Output:
```
'�',
�'�', �
'�',
�'�', �
'�',
�'�', �

```

Reply via email to