Skip to content
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 @@ -4410,7 +4410,7 @@ .ForwardHelpCategory Cmdlet
// Variable which controls the encoding for piping data to a NativeCommand
new SessionStateVariableEntry(
SpecialVariables.OutputEncoding,
System.Text.Encoding.ASCII,
Utils.utf8NoBom,
RunspaceInit.OutputEncodingDescription,
ScopedItemOptions.None,
new ArgumentTypeConverterAttribute(typeof(System.Text.Encoding))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ internal void Start(Process process, NativeCommandIOFormat inputFormat)
//from the current scope so a script or function can use a different encoding
//than global value.
Encoding pipeEncoding = _command.Context.GetVariableValue(SpecialVariables.OutputEncodingVarPath) as System.Text.Encoding ??
Encoding.ASCII;
Utils.utf8NoBom;

_streamWriter = new StreamWriter(process.StandardInput.BaseStream, pipeEncoding);
_streamWriter.AutoFlush = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
Describe 'Native pipeline should have proper encoding' -tags 'CI' {
It '$OutputEncoding should be set to UTF8 without BOM' {
$OutputEncoding.BodyName | Should Be "utf-8"
$OutputEncoding.GetPreamble().Length | Should Be 0
}
}

Describe 'native commands with pipeline' -tags 'Feature' {

BeforeAll {
Expand Down