mirror of
https://github.com/winsw/winsw.git
synced 2025-12-10 18:37:28 +08:00
Set console output code page to UTF-8 (#753)
This commit is contained in:
@@ -8,6 +8,8 @@ namespace WinSW.Native
|
||||
{
|
||||
internal const int ATTACH_PARENT_PROCESS = -1;
|
||||
|
||||
internal const uint CP_UTF8 = 65001;
|
||||
|
||||
[DllImport(Libraries.Kernel32, SetLastError = true)]
|
||||
internal static extern bool AttachConsole(int processId);
|
||||
|
||||
@@ -20,6 +22,9 @@ namespace WinSW.Native
|
||||
[DllImport(Libraries.Kernel32)]
|
||||
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 enum CtrlEvents : uint
|
||||
|
||||
@@ -219,6 +219,8 @@ namespace WinSW.Util
|
||||
|
||||
bool succeeded = SetConsoleCtrlHandler(null, false); // inherited
|
||||
Debug.Assert(succeeded);
|
||||
succeeded = ConsoleApis.SetConsoleOutputCP(ConsoleApis.CP_UTF8);
|
||||
Debug.Assert(succeeded);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user