Skip to content

Set the output encoding to [Console]::OutputEncoding for native commands - #10824

Merged
Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:native-outputencoding
Oct 19, 2019
Merged

Ilya (iSazonov) merged 1 commit into
PowerShell:masterfrom
SteveL-MSFT:native-outputencoding

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Oct 17, 2019 •

Copy link
Copy Markdown
Member

PR Summary

This is a regression from Windows PowerShell due to a breaking change in .NET Core. If you don't explicitly set StandardOutputEncoding, on .NET Core it defaults to the current code page. Previously, it defaulted to Console.OutputEncoding. Fix is to restore Windows PowerShell behavior by explicitly setting StandardOutputEncoding and StandardErrorEncoding to use Console.OutputEncoding.

PR Context

Fix #10789

PR Checklist

@SteveL-MSFT

Copy link
Copy Markdown
Member Author

PoshChan-Bot (@PoshChan) please retry windows

@PoshChan

Copy link
Copy Markdown
Collaborator

Steve Lee (@SteveL-MSFT), successfully started retry of PowerShell-CI-Windows

@iSazonov Ilya (iSazonov) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Oct 19, 2019
@iSazonov Ilya (iSazonov) added this to the 7.0.0-preview.5 milestone Oct 19, 2019
@iSazonov Ilya (iSazonov) changed the title For Native Commands, the output encoding should be set to [Console]::OutputEncoding Set the output encoding to [Console]::OutputEncoding for native commands Oct 19, 2019
@iSazonov
Ilya (iSazonov) merged commit 13f8ba2 into PowerShell:master Oct 19, 2019
@iSazonov

Copy link
Copy Markdown
Collaborator

Interesting, should we do the same for [Console]::InputEncoding too?

@SteveL-MSFT
Steve Lee (SteveL-MSFT) deleted the native-outputencoding branch October 19, 2019 15:56
@SteveL-MSFT

Copy link
Copy Markdown
Member Author

Ilya (@iSazonov) discussed that with James Truher (@JamesWTruher), it seems that the code later overwrites it with the unfortunately named $OutputEncoding (which represents the encoding of output that is input to a native command) so it didn't serve any purpose to change that code.

@Erhie

Erhie commented Oct 26, 2019 •

Copy link
Copy Markdown

is it not able to type

echo €

without problems

this dialog interrupts the normal text input:

cmdlet Write-Output at command pipeline position 1
Supply values for the following parameters:
InputObject[0]: €
InputObject[1]:
€

See also

@ghost

Copy link
Copy Markdown

🎉v7.0.0-preview.6 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Console]::OutputEncoding doesn't work to parse exe with unicode output

5 participants