Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Created December 22, 2018 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guitarrapc/cfc411ebe2447363b4be10ba1e449edc to your computer and use it in GitHub Desktop.
Save guitarrapc/cfc411ebe2447363b4be10ba1e449edc to your computer and use it in GitHub Desktop.
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