1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| ''''replaceunicodechars.vb
Option Strict Off
Option Explicit Off
Imports EnvDTE
Imports System.Diagnostics
Public Module ReplaceUnicodeChars
Sub ReplaceUnicodeChars()
DTE.ExecuteCommand("Edit.Find")
ReplaceAllChar(ChrW(8230),"") ' ellipses
ReplaceAllChar(ChrW(8220),"") ' left double quote
ReplaceAllChar(ChrW(8221),"") ' right double quote
ReplaceAllChar(ChrW(8216),"") ' left single quote
ReplaceAllChar(ChrW(8217),"") ' right single quote
ReplaceAllChar(ChrW(8211),"") ' en dash
ReplaceAllChar(ChrW(8212),"") ' em dash
ReplaceAllChar(ChrW(176),"") ' ?°
ReplaceAllChar(ChrW(188),"") ' ??
ReplaceAllChar(ChrW(189),"") ' ??
ReplaceAllChar(ChrW(169),"") ' ??
ReplaceAllChar(ChrW(174),"") ' ??
ReplaceAllChar(ChrW(8224),"") ' dagger
ReplaceAllChar(ChrW(8225),"") ' double-dagger
ReplaceAllChar(ChrW(185),"") ' ?1
ReplaceAllChar(ChrW(178),"") ' ?2
ReplaceAllChar(ChrW(179),"") ' ?3
ReplaceAllChar(ChrW(153),"") ' a?¢
''ReplaceAllChar(ChrW(0),"")
DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
End Sub
Sub ReplaceAllChar(ByVal findWhat, ByVal replaceWith)
DTE.Find.FindWhat = findWhat
DTE.Find.ReplaceWith = replaceWith
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = False
DTE.Find.MatchWholeWord = False
DTE.Find.MatchInHiddenText = True
DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResultsNone
DTE.Find.Action = vsFindAction.vsFindActionReplaceAll
DTE.Find.Execute()
End Sub
End Module |