Skip to content

Commit

Permalink
Default to no-bom - it'll get switched if one is read
Browse files Browse the repository at this point in the history
But conversely the encoding doesn't get set to no BOM even if no BOM is read
  • Loading branch information
GrahamTheCoder committed Oct 13, 2019
1 parent 96d24c9 commit 03708aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions IncrementVersion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Param($major = $false)

# https://stackoverflow.com/a/9121679/1128762
function Get-FileEncoding($filePath) {
$sr = New-Object System.IO.StreamReader($filePath, $true)
[char[]] $buffer = new-object char[] 3
$sr.Read($buffer, 0, 3) | Out-Null
$sr = New-Object System.IO.StreamReader($filePath, (New-Object System.Text.UTF8Encoding $false), $true)
[char[]] $buffer = new-object char[] 5
$sr.Read($buffer, 0, 5) | Out-Null
$encoding = [System.Text.Encoding] $sr.CurrentEncoding
$sr.Close()
return $encoding
Expand Down

0 comments on commit 03708aa

Please sign in to comment.