Fixer/Character Operations/Illegal Characters/IllegalCharacters.ps1

# Replaces individual ASCII and UNICODE characters

# use this to change illegal characters
# illegal characters may be introduced when scripts are copied from
# web pages or text editors, and typographic changes were made

& {
  # get access to the editor:
  $Editor = Get-SteroidsEditor
  
  # get script content:
  $text = $Editor.Text
  
  # this table controls character replacements
  # the KEY is the hexadecimal value of the character to replace
  # four-digit numbers represent UNICODE characters
  # the VALUE is the character that is used as replacement
  $replacementTable = @{
    
    # UNICODE characters to replace:
    '2013' = '-'
    '2014' = '-'
    '2015' = '-'
    '201C' = '"'
    '201D' = '"'
    '201E' = '"'
    '2018' = "'"
    '2019' = "'"
    '201A' = "'"
    '201B' = "'"
    '2033' = '"'
    '00BB' = '"'
    '02BA' = '"'
    '02BB' = "'"
    '02BC' = "'"
    '02BD' = "'"
    '02DD' = '"'
    '02EE' = '"'
    '02F5' = '"'
    '02F6' = '"'
    '030B' = '"'
    '030F' = '"'
    '0312' = "'"
    '0313' = "'"
    '0314' = "'"
    '0315' = "'"
    
    # ASCII Codes to replace:
    '0001' = ''
    '0002' = ''
    '0003' = ''
    '0004' = ''
    '0005' = ''
    '0006' = ''
    '0007' = ''
    '0008' = ''
    '000B' = ''
    '000C' = ''
    '000E' = ''
    '000F' = ''
  }
  
  # loop through the characters that need replacements
  foreach($UnicodeChar in $replacementTable.Keys)
  {
    # find the instances using a regular expression
    # the return value is always a pair of two:
    # - a MatchCollection returned by Match()
    # - and a string containing the desired replacement character
    
    [Regex]::Matches($text, "\u$UnicodeChar") | Add-SteroidsTextChange -ReplacementText $replacementTable[$UnicodeChar]
  }
  
  # finalize all changes:
  Invoke-SteroidsTextChange  
}


# SIG # Begin signature block
# MIIOggYJKoZIhvcNAQcCoIIOczCCDm8CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFA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