File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Microsoft.VisualStudio.Services.Agent Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,12 @@ public class AgentKnobs
149149 new EnvironmentKnobSource ( "USE_LATEST_GIT_VERSION" ) ,
150150 new BuiltInDefaultKnobSource ( "false" ) ) ;
151151
152+ public static readonly Knob AgentTerminalEncoding = new Knob (
153+ nameof ( AgentTerminalEncoding ) ,
154+ "If the correct encoding name is specified, the encoding from the environment will be used instead of default UTF-8" ,
155+ new EnvironmentKnobSource ( "AGENT_TERMINAL_ENCODING" ) ,
156+ new BuiltInDefaultKnobSource ( string . Empty ) ) ;
157+
152158 public static readonly Knob TfVCUseSecureParameterPassing = new Knob (
153159 nameof ( TfVCUseSecureParameterPassing ) ,
154160 "If true, don't pass auth token in TFVC parameters" ,
Original file line number Diff line number Diff line change 33
44using System ;
55using System . Collections . Generic ;
6+ using System . Text ;
7+ using Agent . Sdk . Knob ;
68using Agent . Sdk . Util ;
79
810namespace Microsoft . VisualStudio . Services . Agent
@@ -37,6 +39,25 @@ public override void Initialize(IHostContext hostContext)
3739 {
3840 base . Initialize ( hostContext ) ;
3941 Console . CancelKeyPress += Console_CancelKeyPress ;
42+
43+ var terminalEncoding = Encoding . UTF8 ;
44+ var endEncodingName = AgentKnobs . AgentTerminalEncoding . GetValue ( hostContext ) . AsString ( ) ;
45+
46+ try
47+ {
48+ if ( ! string . IsNullOrEmpty ( endEncodingName ) )
49+ {
50+ terminalEncoding = Encoding . GetEncoding ( endEncodingName ) ;
51+ }
52+ }
53+ catch ( Exception ex )
54+ {
55+ Trace . Error ( $@ "Encoding ""{ endEncodingName } "" not found:") ;
56+ Trace . Error ( ex ) ;
57+ }
58+
59+ Console . OutputEncoding = terminalEncoding ;
60+ Console . InputEncoding = terminalEncoding ;
4061 }
4162
4263 private void Console_CancelKeyPress ( object sender , ConsoleCancelEventArgs e )
You can’t perform that action at this time.
0 commit comments