encoding - Using PowerShell to write a file in UTF-8 without the BOM -
out-file
seems force bom when using utf-8:
$myfile = get-content $mypath $myfile | out-file -encoding "utf8" $mypath
how can write file in utf-8 no bom using powershell?
using .net's utf8encoding
class , passing $false
constructor seems work:
$myfile = get-content $mypath $utf8nobomencoding = new-object system.text.utf8encoding $false [system.io.file]::writealllines($mypath, $myfile, $utf8nobomencoding)
Comments
Post a Comment