Skip to content

Commit ad65a5e

Browse files
authored
Set console encoding to UTF8 (#4649)
1 parent 108a37c commit ad65a5e

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/Microsoft.TestPlatform.CoreUtilities/FeatureFlag/FeatureFlag.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ private FeatureFlag() { }
5757
// Disable the SerialTestRunDecorator
5858
public const string DISABLE_SERIALTESTRUN_DECORATOR = VSTEST_ + nameof(DISABLE_SERIALTESTRUN_DECORATOR);
5959

60+
// Disable setting UTF8 encoding in console.
61+
public const string DISABLE_UTF8_CONSOLE_ENCODING = VSTEST_ + nameof(DISABLE_UTF8_CONSOLE_ENCODING);
62+
6063
[Obsolete("Only use this in tests.")]
6164
internal static void Reset()
6265
{

src/vstest.console/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
using System.Text;
5+
using System;
6+
47
using Microsoft.VisualStudio.TestPlatform.Execution;
58
using Microsoft.VisualStudio.TestPlatform.Utilities;
69

@@ -20,6 +23,10 @@ public static class Program
2023

2124
internal static int Run(string[]? args, UiLanguageOverride uiLanguageOverride)
2225
{
26+
if (!FeatureFlag.Instance.IsSet(FeatureFlag.DISABLE_UTF8_CONSOLE_ENCODING))
27+
{
28+
Console.OutputEncoding = Encoding.UTF8;
29+
}
2330
uiLanguageOverride.SetCultureSpecifiedByUser();
2431
return new Executor(ConsoleOutput.Instance).Execute(args);
2532
}

0 commit comments

Comments
 (0)