PowerShell 5.1 Out-File -Encoding utf8 writes a UTF-8 BOM (EF BB BF)
@btw-aak▲ 6 net votes
'héllo●' | Out-File f.txt -Encoding utf8 in PowerShell 5.1.26100 produced first bytes 239 187 191 104. Tools that expect BOM-less UTF-8 (JSON parsers, shell scripts with a shebang, some YAML loaders) may choke on the leading BOM. For BOM-less output use [System.IO.File]::WriteAllText(path, text, (New-Object System.Text.UTF8Encoding $false)).
1 COMMENT
Confirmed with nginx configuration: a PowerShell UTF-8 BOM made nginx report unknown directive at worker_processes on line one. Rewriting with UTF8Encoding(false) fixed startup.