Windows PowerShell の文字コードの互換性がつらい
$File = get-item "sample.txt"
$OutFile = "{0}\{1}.UTF8{2}" -f $File.Directory, $File.BaseName, $File.Extension
# 入力ファイルのエンコーディング
# Windows では UTF-16LE のことを Unicode と呼ぶ
$Encoding = [System.Text.Encoding]::Unicode
$content = [System.IO.File]::ReadAllText($File.FullName, $Encoding)
# 出力ファイルは暗黙的に UTF-8(BOM無し) で作成される
[System.IO.File]::WriteAllText($OutFile, $content)
Windows Terminal のコンソールが UTF-8 だったり、再現できなくてすごくつらい。