[Issue 8600] New: "writeln" one parameter garbled
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Aug 30 04:57:53 PDT 2012
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 at puremagic.com
ReportedBy: vi at vi-li.com
--- Comment #0 from Lo <vi at vi-li.com> 2012-08-30 04:57:50 PDT ---
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: -------
More information about the Digitalmars-d-bugs
mailing list