Thread overview | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 24, 2019 What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Hi,everyone, for example: import std.stdio; import std.process:executeShell; extern(C) int setlocale(int,char*); static this() { import core.stdc.wchar_; import core.stdc.stdio; fwide(core.stdc.stdio.stdout,1); setlocale(0,cast(char*)"china"); } void main() { writeln("字符"); executeShell("pause"); } ///////////////////////code end///////////////////////////// In D2.078.1 It works very ok. But After D2.080 ,It not works. Who can help me? Thank you. |
January 24, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | On Thursday, 24 January 2019 at 07:48:44 UTC, FrankLike wrote:
> Hi,everyone,
>
> for example:
>
> import std.stdio;
> import std.process:executeShell;
>
> extern(C) int setlocale(int,char*);
>
> static this()
> {
> import core.stdc.wchar_;
> import core.stdc.stdio;
> fwide(core.stdc.stdio.stdout,1);
> setlocale(0,cast(char*)"china");
> }
>
> void main()
> {
> writeln("字符");
> executeShell("pause");
> }
> ///////////////////////code end/////////////////////////////
In D2.078.1 It can display Chinese characters correctly!
But After D2.080 , but it can't be used now.
Who can help me?
Thank you.
|
January 24, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | Try workarounds here: https://issues.dlang.org/show_bug.cgi?id=1448 https://issues.dlang.org/show_bug.cgi?id=2742 |
January 24, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, 24 January 2019 at 12:19:44 UTC, Kagamin wrote:
> Try workarounds here:
> https://issues.dlang.org/show_bug.cgi?id=1448
> https://issues.dlang.org/show_bug.cgi?id=2742
Ok,thank you.
import std.stdio;
import core.sys.windows.windows;
import std.process:executeShell;
extern(Windows) bool SetConsoleOutputCP(uint);
void main()
{
SetConsoleOutputCP(65001);
writeln("字符");
executeShell("pause");
}
|
January 25, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Thursday, 24 January 2019 at 12:19:44 UTC, Kagamin wrote:
> Try workarounds here:
> https://issues.dlang.org/show_bug.cgi?id=1448
> https://issues.dlang.org/show_bug.cgi?id=2742
How do I set the font? Please.
|
January 25, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | Create a shortcut to cmd.exe and edit its properties. The console window itself has a system menu for this too. |
January 25, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Friday, 25 January 2019 at 08:41:23 UTC, Kagamin wrote:
> Create a shortcut to cmd.exe and edit its properties. The console window itself has a system menu for this too.
I known that.
I need to set the font by the code now, because I need to do the installer, can't let this installer set the properties on each computer?
Thank you.
|
January 25, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | On Friday, 25 January 2019 at 14:23:15 UTC, FrankLike wrote: > I need to set the font by the code now, because I need to do the installer, can't let this installer set the properties on each computer? SetCurrentConsoleFontEx perhaps? https://docs.microsoft.com/en-us/windows/console/setcurrentconsolefontex |
January 25, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to FrankLike | also http://blogs.microsoft.co.il/pavely/2009/07/23/changing-console-fonts/ |
January 26, 2019 Re: What is the alternative to the setlocale function of c in D? Thank you. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Friday, 25 January 2019 at 16:14:56 UTC, Kagamin wrote: > also http://blogs.microsoft.co.il/pavely/2009/07/23/changing-console-fonts/ That's so much code than next code! ///////////////////////////////// extern(C) int setlocale(int,char*); static this() { import core.stdc.wchar_; import core.stdc.stdio; fwide(core.stdc.stdio.stdout,1); setlocale(0,cast(char*)"china"); } ///////////////////////////////////////// After D2.078.1,it's not work. why? thank you. |
Copyright © 1999-2021 by the D Language Foundation