Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set console encoding to UTF8 #4649

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ private FeatureFlag() { }
// Disable the SerialTestRunDecorator
public const string DISABLE_SERIALTESTRUN_DECORATOR = VSTEST_ + nameof(DISABLE_SERIALTESTRUN_DECORATOR);

// Disable setting UTF8 encoding in console.
public const string DISABLE_UTF8_CONSOLE_ENCODING = VSTEST_ + nameof(DISABLE_UTF8_CONSOLE_ENCODING);

[Obsolete("Only use this in tests.")]
internal static void Reset()
{
Expand Down
7 changes: 7 additions & 0 deletions src/vstest.console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Text;
using System;

using Microsoft.VisualStudio.TestPlatform.Execution;
using Microsoft.VisualStudio.TestPlatform.Utilities;

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

internal static int Run(string[]? args, UiLanguageOverride uiLanguageOverride)
{
if (!FeatureFlag.Instance.IsSet(FeatureFlag.DISABLE_UTF8_CONSOLE_ENCODING))
{
Console.OutputEncoding = Encoding.UTF8;
}
uiLanguageOverride.SetCultureSpecifiedByUser();
return new Executor(ConsoleOutput.Instance).Execute(args);
}
Expand Down