Merge pull request #4425 from microsoft/mikebattista/#4423

Update /_utils/Set-All-Text-File-Template-Encodings.ps1 to support PowerShell Core
This commit is contained in:
Mike Battista 2022-03-30 16:21:04 -07:00 коммит произвёл GitHub
Родитель fe8cddd779 ded5e5fd32
Коммит ae61901436
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 9 добавлений и 1 удалений

Просмотреть файл

@ -8,6 +8,14 @@
# Any files that don't have the desired encoding will be changed
# so they are encoded as desired.
if ($PSVersionTable.PSEdition -eq "Desktop") {
Write-Host "The latest version of PowerShell is required to run this script. Windows PowerShell is not supported."
Write-Host ""
Write-Host "Install the latest stable release of PowerShell from https://aka.ms/powershell-release?tag=stable."
return;
}
function Is-EncodedCorrectly
{
[OutputType([Boolean])]
@ -17,7 +25,7 @@ function Is-EncodedCorrectly
[string]$Path
)
[byte[]]$byte = get-content -Encoding byte -ReadCount 3 -TotalCount 3 -Path $Path
[byte[]]$byte = Get-Content -AsByteStream -Raw -Path $Path
# EF BB BF (UTF8 + BOM)
if ( $byte[0] -eq 0xef -and $byte[1] -eq 0xbb -and $byte[2] -eq 0xbf )