Created
April 15, 2019 21:42
-
-
Save Chirishman/158da7f0bd14668fa64546400bb91689 to your computer and use it in GitHub Desktop.
Function to convert a file on disk to UTF8-NoBOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-UTF8 { | |
Param( | |
[ValidatePathExists()] | |
[System.IO.FileInfo]$Path | |
) | |
[string]$Contents = (Get-Content -Path $Path) -join "`r`n" | |
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False | |
[System.IO.File]::WriteAllLines($Path, $Contents, $Utf8NoBomEncoding) | |
Write-Information -MessageData "File $Path has been converted" -InformationAction Continue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment