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: nob...@puremagic.com
        ReportedBy: brad.lanam.c...@gmail.com


--- Comment #0 from Brad L <brad.lanam.c...@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: -------

Reply via email to