UTF-8 char and write(f)ln
Ali Çehreli
acehreli at yahoo.com
Wed Mar 5 17:56:25 UTC 2025
On 3/4/25 12:09 AM, Vindex9 wrote:
> 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 '�'
> τ
[...]
> How does the second writefln know about the context and can adequately
> output a character on every other iteration?
It shouldn't and does not work in my environment (both inside an Emacs
buffer and inside a Linux terminal).
I think you are running your program in an environment where 132 is
mapped to τ, etc. Perhaps a "code page" setting is helping (or hurting)
you there?
Ali
More information about the Digitalmars-d-learn
mailing list