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');
}
}
Comment #1 by bugzilla — 2021-02-20T14:21:23Z
I get:
test.d(6): Error: undefined identifier stdio in package core.stdc, perhaps add static import core.stdc.stdio;
making the import static, like suggested yields:
test.d(6): Error: undefined identifier fwide
A working example (or a description what fails) would be nice...
Comment #2 by bugzilla — 2021-04-12T18:01:41Z
I'm closing this, because it's unclear, what the bug is and the report is old, so it might not even be there anymore. Please feel free to reopen it, if you think, the bug still persists.
Comment #3 by ag0aep6g — 2021-04-13T10:49:31Z
(In reply to Berni44 from comment #2)
> I'm closing this, because it's unclear, what the bug is and the report is
> old, so it might not even be there anymore. Please feel free to reopen it,
> if you think, the bug still persists.
Reopening. The code is just missing some imports. Fixed test case:
----
import core.stdc.wchar_, core.stdc.locale;
static import core.stdc.stdio;
import std.stdio: writeln;
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;
}
----
Comment #4 by bugzilla — 2021-04-13T11:07:22Z
Thanks. That makes more sense. I guess the expected output should be "1个" instead of "1?,?"?
Comment #5 by robert.schadek — 2024-12-01T16:15:38Z