Skip to content

Commit 03708aa

Browse files
Default to no-bom - it'll get switched if one is read
But conversely the encoding doesn't get set to no BOM even if no BOM is read
1 parent 96d24c9 commit 03708aa

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

IncrementVersion.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ Param($major = $false)
22

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

0 commit comments

Comments
 (0)