Wired question related with Chinese characters

lovemini lovemini at gmail.com
Sun Mar 29 10:36:53 UTC 2020


import std.stdio;

void main()
{
	version( Windows ) {
		//直接运行中文显示乱码,原因在于Windows控制台默认编码为 936,而D语言输出utf-8
		//可以将控制台编码修改为 utf-8,命令为 "CHCP 65001"
		//修改后就可以显示中文了
		import core.sys.windows.windows;
		SetConsoleCP(65001);
		SetConsoleOutputCP( 65001 );
	}

     writeln("Hello World! 你好,中国!");
}



More information about the Digitalmars-d-learn mailing list