Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"writeln" one parameter garbled #9938

Open
dlangBugzillaToGithub opened this issue Aug 30, 2012 · 4 comments
Open

"writeln" one parameter garbled #9938

dlangBugzillaToGithub opened this issue Aug 30, 2012 · 4 comments

Comments

@dlangBugzillaToGithub
Copy link

vi reported this on 2012-08-30T04:57:50Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=8600

CC List

Description

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('
', .stdout.p.handle) == '
');
    }
    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
",
        //                cast(int) args[0].length, args[0].ptr) >= 0);

		stdout.write(args, '
');
    }
    else
    {
        // Most general instance
        stdout.write(args, '
');
    }
}
@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 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...

@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 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.

@dlangBugzillaToGithub
Copy link
Author

ag0aep6g commented on 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;
}
----

@dlangBugzillaToGithub
Copy link
Author

bugzilla (@WalterBright) commented on 2021-04-13T11:07:22Z

Thanks. That makes more sense. I guess the expected output should be "1个" instead of "1?,?"?

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants