Skip to content

Commit

Permalink
Merge pull request #397 from dahlbyk/utf8•if•single•byte
Browse files Browse the repository at this point in the history
Only override OutputEncoding if single-byte
  • Loading branch information
dahlbyk authored Feb 3, 2017
2 parents 988a9ce + 5068f5f commit 5ef283d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ function Invoke-Utf8ConsoleCommand([ScriptBlock]$cmd) {
# A native executable that writes to stderr AND has its stderr redirected will generate non-terminating
# error records if the user has set $ErrorActionPreference to Stop. Override that value in this scope.
$ErrorActionPreference = 'Continue'
[Console]::OutputEncoding = [Text.Encoding]::UTF8
if ($currentEncoding.IsSingleByte) {
[Console]::OutputEncoding = [Text.Encoding]::UTF8
}
& $cmd
}
finally {
[Console]::OutputEncoding = $currentEncoding
if ($currentEncoding.IsSingleByte) {
[Console]::OutputEncoding = $currentEncoding
}

# Clear out stderr output that was added to the $Error collection, putting those errors in a module variable
if ($global:Error.Count -gt $errorCount) {
Expand Down

0 comments on commit 5ef283d

Please sign in to comment.