Using .NET's
One line
Read full article from encoding - Using PowerShell to write a file in UTF-8 without the BOM - Stack Overflow
UTF8Encoding class and passing $False to the constructor seems to work:$MyFile = Get-Content $MyPath $Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding($False) [System.IO.File]::WriteAllLines($MyPath, $MyFile, $Utf8NoBomEncoding)
One line
[System.IO.File]::WriteAllLines($MyPath, $MyFile) is enough. This WriteAllLinesoverload writes exactly UTF8 without BOM. Read full article from encoding - Using PowerShell to write a file in UTF-8 without the BOM - Stack Overflow
No comments:
Post a Comment