From 2ba6da351425a177a116eb1a94f6d6a76aab7fe9 Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Thu, 25 Mar 2021 22:19:49 +0200 Subject: [PATCH] Respect encoding of `TextWriter` provided to `AnsiConsole.Create(...)` --- src/Spectre.Console/AnsiConsoleFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Spectre.Console/AnsiConsoleFactory.cs b/src/Spectre.Console/AnsiConsoleFactory.cs index cb4d541..451fd1f 100644 --- a/src/Spectre.Console/AnsiConsoleFactory.cs +++ b/src/Spectre.Console/AnsiConsoleFactory.cs @@ -28,8 +28,8 @@ namespace Spectre.Console // Detect if the terminal support ANSI or not var (supportsAnsi, legacyConsole) = DetectAnsi(settings, buffer); - // Use the provided encoding or fall back to UTF-8 - var encoding = buffer.IsStandardOut() || buffer.IsStandardError() ? System.Console.OutputEncoding : Encoding.UTF8; + // Use console encoding or fall back to provided encoding + var encoding = buffer.IsStandardOut() || buffer.IsStandardError() ? System.Console.OutputEncoding : buffer.Encoding; // Get the color system var colorSystem = settings.ColorSystem == ColorSystemSupport.Detect