Thread overview | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
December 02, 2011 [Issue 7054] New: formatting fixed width string fields w/utf | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=7054 Summary: formatting fixed width string fields w/utf Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P5 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: brad.lanam.comp@gmail.com --- Comment #0 from Brad L <brad.lanam.comp@gmail.com> 2011-12-02 11:00:52 PST --- Using a width specifier in conjunction with a utf string fails. It would be nice to have a %S modifier that handles this situation. 123456789012345 Größe: incorrect Größe: correct Größe : incorrect Größe : correct Grö : incorrect Größ : correct import std.stdio; import std.string; import std.utf : count; void main (string[] args) { string t = "Größe"; size_t width = 10; auto len = t.length; auto utflen = std.utf.count (t); auto tlen = width + len - utflen; writefln ("123456789012345"); writefln ("%10s: incorrect", t); writefln ("%*s: correct", tlen, t); writefln ("%-10s: incorrect", t); writefln ("%-*s: correct", tlen, t); writefln ("%-10.4s: incorrect", t); auto fmt = format ("%%-%d.%ds: correct", tlen, tlen - 6); writefln (fmt, t); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
December 05, 2011 [Issue 7054] writef formats strings containing UTF-8 multibyte characters to the wrong width | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad L | http://d.puremagic.com/issues/show_bug.cgi?id=7054 Stewart Gordon <smjg@iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |spec CC| |smjg@iname.com Summary|formatting fixed width |writef formats strings |string fields w/utf |containing UTF-8 multibyte | |characters to the wrong | |width Severity|enhancement |normal --- Comment #1 from Stewart Gordon <smjg@iname.com> 2011-12-04 18:08:04 PST --- (In reply to comment #0) > Using a width specifier in conjunction with a utf string fails. It would be nice to have a %S modifier that handles this situation. We shouldn't need a different format specifier for this. It's a matter of what "Width" means in the format string spec, not one of different kinds of string format. http://www.d-programming-language.org/phobos/std_format.html "Specifies the minimum field width. If the width is a *, the next argument, which must be of type int, is taken as the width. If the width is negative, it is as if the - was given as a Flags character." While it doesn't specify the units the width is measured in, it seems a reasonable assumption that it is intended to be characters, rather than bytes. Indeed, 1.071's version gets it right, so clearly the bug is in the D2 line's implementation. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 24, 2012 [Issue 7054] writef formats strings containing UTF-8 multibyte characters to the wrong width | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad L | http://d.puremagic.com/issues/show_bug.cgi?id=7054 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|spec | CC| |bugzilla@digitalmars.com Component|DMD |Phobos --- Comment #2 from Walter Bright <bugzilla@digitalmars.com> 2012-01-24 01:50:59 PST --- This is a bug in Phobos, not the compiler or spec. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
July 06, 2012 [Issue 7054] std.format.formattedWrite uses code units count as width instead of characters count | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brad L | http://d.puremagic.com/issues/show_bug.cgi?id=7054 Denis Shelomovskij <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P5 |P4 CC| |verylonglogin.reg@gmail.com Summary|writef formats strings |std.format.formattedWrite |containing UTF-8 multibyte |uses code units count as |characters to the wrong |width instead of characters |width |count -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation