Functions/Get-StringValueWithoutBom.ps1
<#
.SYNOPSIS This function returns the given string without the byte-order mark (BOM) at the beginning, if it exists. .DESCRIPTION This function returns the given string without the byte-order mark (BOM) at the beginning, if it exists. https://www.w3.org/International/questions/qa-byte-order-mark #> function Get-StringValueWithoutBom { [CmdletBinding()] [OutputType([String])] param ( [Parameter(Mandatory=$true)] [ValidateNotNull()] [String]$string ) # Check for the BOM if ($string.length -gt 0 -and [Int]$string[0] -eq 65279) { return $string[1..($string.length - 1)] -join "" } # Return the same string return $string } |