[Issue 203] New: std.format.doFormat() pads width incorrectly on Unicode strings

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jun 17 10:13:49 PDT 2006


http://d.puremagic.com/issues/show_bug.cgi?id=203

           Summary: std.format.doFormat() pads width incorrectly on Unicode
                    strings
           Product: D
           Version: 0.160
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: deewiant at gmail.com


import std.string;

void main() {
        assert(format("%8s", "foo")             == "     foo");
        assert(format("%8s", "foobar")          == "  foobar");
        assert(format("%8s", "hello")           == "   hello");
        assert(format("%8s", "h\u00e9ll\u00f4") == "   h\u00e9ll\u00f4");
        // this passes, though it shouldn't: assert(format("%8s",
"h\u00e9ll\u00f4") == " h\u00e9ll\u00f4");
}
--

In the above, the last assertion fails.

One would expect the last two strings, having five characters each, to both be
padded in the front by three spaces: however, it appears the byte count is
being used for determining the length and not the actual character count, and
so the last string is padded by only one space.


-- 




More information about the Digitalmars-d-bugs mailing list