Skip to content

Commit

Permalink
Set console encoding to UTF8.
Browse files Browse the repository at this point in the history
  • Loading branch information
nohwnd committed Aug 8, 2023
1 parent d21ac0a commit 72cb6a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Expand Up @@ -57,6 +57,9 @@ internal partial class FeatureFlag : IFeatureFlag
// 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
@@ -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

0 comments on commit 72cb6a8

Please sign in to comment.