Jump to page: 1 2
Thread overview
What is the alternative to the setlocale function of c in D? Thank you.
Jan 24, 2019
FrankLike
Jan 24, 2019
FrankLike
Jan 24, 2019
Kagamin
Jan 24, 2019
FrankLike
Jan 25, 2019
FrankLike
Jan 25, 2019
Kagamin
Jan 25, 2019
FrankLike
Jan 25, 2019
John Chapman
Jan 26, 2019
FrankLike
Jan 26, 2019
John Chapman
Jan 27, 2019
FrankLike
Jan 27, 2019
John Chapman
Jan 27, 2019
FrankLike
Jan 28, 2019
John Chapman
Jan 25, 2019
Kagamin
Jan 26, 2019
FrankLike
January 24, 2019
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
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
Try workarounds here:
https://issues.dlang.org/show_bug.cgi?id=1448
https://issues.dlang.org/show_bug.cgi?id=2742
January 24, 2019
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
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
Create a shortcut to cmd.exe and edit its properties. The console window itself has a system menu for this too.
January 25, 2019
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
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
also http://blogs.microsoft.co.il/pavely/2009/07/23/changing-console-fonts/
January 26, 2019
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.
« First   ‹ Prev
1 2