www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8600] New: "writeln" one parameter garbled

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

           Summary: "writeln" one parameter garbled
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: vi vi-li.com



import core.stdc.wchar_,core.stdc.locale;

example code:

extern(C) int setlocale(int, char*);   
static this()   
{   
    fwide(core.stdc.stdio.stdout, 1);   
    setlocale(0, cast(char*)"china");      
}
int main(string[] argv)
{
   writeln("1δΈͺ");
   return 0;
}


Temporary fix:

void writeln(T...)(T args)
{
    static if (T.length == 0)
    {
        enforce(fputc('\n', .stdout.p.handle) == '\n');
    }
    else static if (T.length == 1 &&
                    isSomeString!(typeof(args[0])) && is(typeof(args[0]) :
const(char)[]) &&
                    !isAggregateType!(typeof(args[0])))
    {
        // error: not Transformation coding

        // Specialization for strings - a very frequent case
        //enforce(fprintf(.stdout.p.handle, "%.*s\n",
        //                cast(int) args[0].length, args[0].ptr) >= 0);

        stdout.write(args, '\n');
    }
    else
    {
        // Most general instance
        stdout.write(args, '\n');
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 30 2012