If I run a command like this:
Write-Output March > a.txt
I get this result:
U+FEFF
M U+004D
a U+0061
r U+0072
c U+0063
h U+0068
U+000D
U+000A
I do not want the BOM. I tried different actions, like this:
$OutputEncoding = [System.Text.UTF8Encoding]::new($false)
$PSDefaultParameterValues['*:Encoding'] = 'utf8'
[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)
[Console]::OutputEncoding = [System.Text.UTF8Encoding]::new($false)
but none of them seem to address the issue. Note I am using PowerShell 5.1. I
did see some similar questions, but not quite the same issue as this, as they
were dealing with piping and external commands.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…