$files = Get-ChildItem -Path "site" -Recurse -Include "*.html", "*.js", "*.css" | Select-Object -ExpandProperty FullName
foreach ($file in $files) {
    $content = Get-Content $file -Raw -Encoding UTF8

    $ellipsis = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x00A6
    $content = $content.Replace($ellipsis, '...')

    $arrow = [string][char]0x00E2 + [string][char]0x2020 + [string][char]0x2019
    $content = $content.Replace($arrow, '&rarr;')

    $emdash = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x201D
    $content = $content.Replace($emdash, '&mdash;')

    $endash = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x201C
    $content = $content.Replace($endash, '&ndash;')

    $bullet = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x00A2
    $content = $content.Replace($bullet, '&bull;')

    $middot = [string][char]0x00C2 + [string][char]0x00B7
    $content = $content.Replace($middot, '&middot;')

    $rsquot = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x2122
    $content = $content.Replace($rsquot, "'")

    $lsquot = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x02DC
    $content = $content.Replace($lsquot, "'")

    $rdquot = [string][char]0x00E2 + [string][char]0x20AC + [string][char]0x0153
    $content = $content.Replace($rdquot, '"')
    
    $space = [string][char]0x00C2 + " "
    $content = $content.Replace($space, ' ')

    Set-Content -Path $file -Value $content -Encoding UTF8
}
Write-Host "Fixed mojibake across site."
