mirror of https://github.com/winsw/winsw
Set console output code page to UTF-8 (#753)
parent
4f7e623602
commit
16c6aa9c08
|
@ -8,6 +8,8 @@ namespace WinSW.Native
|
||||||
{
|
{
|
||||||
internal const int ATTACH_PARENT_PROCESS = -1;
|
internal const int ATTACH_PARENT_PROCESS = -1;
|
||||||
|
|
||||||
|
internal const uint CP_UTF8 = 65001;
|
||||||
|
|
||||||
[DllImport(Libraries.Kernel32, SetLastError = true)]
|
[DllImport(Libraries.Kernel32, SetLastError = true)]
|
||||||
internal static extern bool AttachConsole(int processId);
|
internal static extern bool AttachConsole(int processId);
|
||||||
|
|
||||||
|
@ -20,6 +22,9 @@ namespace WinSW.Native
|
||||||
[DllImport(Libraries.Kernel32)]
|
[DllImport(Libraries.Kernel32)]
|
||||||
internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine? handlerRoutine, bool add);
|
internal static extern bool SetConsoleCtrlHandler(ConsoleCtrlHandlerRoutine? handlerRoutine, bool add);
|
||||||
|
|
||||||
|
[DllImport(Libraries.Kernel32)]
|
||||||
|
internal static extern bool SetConsoleOutputCP(uint codePageID);
|
||||||
|
|
||||||
internal delegate bool ConsoleCtrlHandlerRoutine(CtrlEvents ctrlType);
|
internal delegate bool ConsoleCtrlHandlerRoutine(CtrlEvents ctrlType);
|
||||||
|
|
||||||
internal enum CtrlEvents : uint
|
internal enum CtrlEvents : uint
|
||||||
|
|
|
@ -219,6 +219,8 @@ namespace WinSW.Util
|
||||||
|
|
||||||
bool succeeded = SetConsoleCtrlHandler(null, false); // inherited
|
bool succeeded = SetConsoleCtrlHandler(null, false); // inherited
|
||||||
Debug.Assert(succeeded);
|
Debug.Assert(succeeded);
|
||||||
|
succeeded = ConsoleApis.SetConsoleOutputCP(ConsoleApis.CP_UTF8);
|
||||||
|
Debug.Assert(succeeded);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue