[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
Fri Aug 29 14:31:59 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=7054
--- Comment #5 from hsteoh at quickfur.ath.cx ---
Because grapheme clustering is the only sane way to handle output to a field of
fixed length. For example, writeln("%5s", "a\u0301") should treat "a\u0301" as
occupying only a single position in the 5-position wide output field.
Any other solution would introduce further problems, e.g. if we count code
points instead, then the width field in the format string would be basically
useless (the caller will have to manually count output positions -- with
byGrapheme -- and adjust the width accordingly). Furthermore, it would
introduce more special cases (precomposed characters will format differently
from base char + combining diacritic; non-spacing characters will consume field
width but occupy no space in the actual output, etc.).
--
More information about the Digitalmars-d-bugs
mailing list