diff --git a/src/Program.cs b/src/Program.cs index b710776..678717f 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,4 +1,5 @@ using System.Reflection; +using System.Text; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Serilog; @@ -13,6 +14,8 @@ using fuseraft.Infrastructure; using fuseraft.Infrastructure.Plugins; +ConfigureConsoleEncoding(); + // Catch crashes on background threads (not covered by Spectre's SetExceptionHandler). AppDomain.CurrentDomain.UnhandledException += (_, e) => { @@ -226,3 +229,12 @@ { await Log.CloseAndFlushAsync(); } + +static void ConfigureConsoleEncoding() +{ + try { Console.OutputEncoding = Encoding.UTF8; } + catch (Exception ex) when (ex is IOException or NotSupportedException or UnauthorizedAccessException) { } + + try { Console.InputEncoding = Encoding.UTF8; } + catch (Exception ex) when (ex is IOException or NotSupportedException or UnauthorizedAccessException) { } +}