# 把 UTF-8 的 bat 內容轉成 Big5(cp950)+ CRLF,輸出成「啟動.bat」 # 啟=U+555F 動=U+52D5(用碼位組檔名,避免中文在命令列被破壞) $dir = 'E:\videos\redlight_remover' $src = Join-Path $dir '_bat_src.txt' $dst = Join-Path $dir ([string][char]0x555F + [string][char]0x52D5 + '.bat') $lines = Get-Content -Encoding UTF8 $src $t = [string]::Join([char]13 + [char]10, $lines) + [char]13 + [char]10 $enc = [Text.Encoding]::GetEncoding(950) [IO.File]::WriteAllText($dst, $t, $enc) # 回讀驗證:若有字元無法以 Big5 表示會變成 '?',回讀就不會相等 $b = [IO.File]::ReadAllText($dst, $enc) $bytes = [IO.File]::ReadAllBytes($dst).Length Write-Output ("DST=" + $dst) Write-Output ("BYTES=" + $bytes) if ($t -eq $b) { Write-Output 'ROUNDTRIP_OK' } else { Write-Output 'ROUNDTRIP_MISMATCH' }