$files = Get-ChildItem -Path "site\*.html", "site\tools\*.html", "site\blog\articles\*.html" -Recurse

# The corrupted sequence is the Unicode Replacement Character (U+FFFD) followed by ?"
# We construct it safely so it doesn't break PowerShell parsing.
$badString = [char]0xFFFD + '?"'
$goodString = '—' # em-dash

foreach ($file in $files) {
    if ($file.Extension -ne ".html") { continue }
    
    $content = [IO.File]::ReadAllText($file.FullName, [System.Text.Encoding]::UTF8)
    
    if ($content.Contains($badString)) {
        $content = $content.Replace($badString, $goodString)
        [IO.File]::WriteAllText($file.FullName, $content, [System.Text.Encoding]::UTF8)
        Write-Host "Fixed corrupt symbols in $($file.Name)"
    }
}
Write-Host "All unwanted symbols fixed safely."
