[Issue 7054] std.format.formattedWrite uses code units count as width instead of characters count

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 15 04:07:58 PST 2016


https://issues.dlang.org/show_bug.cgi?id=7054

--- Comment #9 from Marco Leise <Marco.Leise at gmx.de> ---
I always regarded it as merely a means to print stuff with a non-proportional
font for humans to read that extends to text files. The match up of bytes and
visual characters in the early days printf is only a historical coincidence.

Most terminals - like programming languages and GUI toolkits - have to adapt to
the Unicode reality and I believe it is safe to assume that when someone calls
writefln or format with full-width symbols they use a terminal that can handle
them. The popular VTE library used by many recent Linux terminal emulators
works great for example.

That said, printf is no better, and we could just claim that the width is meant
to mean bytes or ASCII characters and you are supposed to use writefln only for
English text in debugging output and not user interaction. std.stdio never
cared about the user locale anyways. For all we know the output terminal might
expect KOI-8 (Cyrillic) or some Indian script. In Java for example you are
supposed to use an encoding wrapper if your stdout goes to a terminal, IIRC.
But as Unicode is kind of ubiquitous now, we might as well say that Dlang only
works on Unicode enabled systems. Sorry for the derail ... :)

--


More information about the Digitalmars-d-bugs mailing list