[Issue 7054] New: formatting fixed width string fields w/utf
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Fri Dec  2 11:01:56 PST 2011
    
    
  
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 at puremagic.com
        ReportedBy: brad.lanam.comp at gmail.com
--- Comment #0 from Brad L <brad.lanam.comp at 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: -------
    
    
More information about the Digitalmars-d-bugs
mailing list