mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Adds the $PSApplicationOutputEncoding variable that can be used to control the encoding PowerShell uses when reading the raw bytes to a string of an external application.
24 lines
437 B
PowerShell
24 lines
437 B
PowerShell
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
[CmdletBinding()]
|
|
param (
|
|
[Parameter(Mandatory)]
|
|
[string]
|
|
$Value,
|
|
|
|
[Parameter(Mandatory)]
|
|
[string]
|
|
$Encoding
|
|
)
|
|
|
|
$enc = [System.Text.Encoding]::GetEncoding($Encoding)
|
|
$data = $enc.GetBytes($Value)
|
|
|
|
$outStream = [System.Console]::OpenStandardOutput()
|
|
try {
|
|
$outStream.Write($data, 0, $data.Length)
|
|
} finally {
|
|
$outStream.Dispose()
|
|
}
|