mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-30 21:35:11 +08:00
Change $OutputEncoding to be utf8 without BOM rather than ASCII (#5369)
This commit is contained in:
parent
610c70d952
commit
fe3e44f305
@ -4410,7 +4410,7 @@ end
|
||||
// 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))
|
||||
|
@ -1798,7 +1798,7 @@ namespace System.Management.Automation
|
||||
//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;
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user