Created
December 22, 2018 15:26
-
-
Save guitarrapc/cfc411ebe2447363b4be10ba1e449edc to your computer and use it in GitHub Desktop.
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 Test-Utf8BomHeader { | |
[CmdletBinding(DefaultParameterSetName = "File")] | |
[OutputType([bool])] | |
param( | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = "File")] | |
[System.IO.FileInfo]$File, | |
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = "Path")] | |
[Alias("LiteralPath", "PSPath")] | |
[string]$Path | |
) | |
process { | |
if ($PSBoundParameters.ContainsKey("File")) { | |
$header = [FileHeader]::Read($File, $removeOffset) | |
Write-Output ($header -eq $bomHex) | |
} | |
else { | |
$header = [FileHeader]::Read($Path, $removeOffset) | |
Write-Output ($header -eq $bomHex) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment