弥补Reflector反编译对中文支持的不足

    Reflector是我目前用的最多的反编译工具,他可能不时最好的,但以它的更新速度,我相信他会成为最好的哦~~
    国外的软件,对中文支持还是有问题,虽然我们都Unicode了,可是老外还是不一定认账。Reflector反编译代码,Unicode中非英文的字符都显示为了\u????,这本来还是对的,可是我们看起来就太郁闷了。Reflector支持Plug-in,曾经想写个插件,结果要了解的东西太多,就放弃了。不过问题也解决了,用VS.NET带的宏,haha

   转换前的代码,谁能看懂写的啥呀@_@?
   

    不要担心,转换后的代码就成了:
   

    VS.NET 宏代码,名称:Unicode2Character

Public Module Birdshome
   Sub Unicode2Character()
       Dim doc As Document = DTE.ActiveDocument
       Dim docText As TextDocument = doc.Object
       Dim selText As TextSelection = docText.Selection()
       selText.SelectAll()
       Dim text As String = selText.Text

       Dim iLength As Integer

       Do
           iLength = text.Length
           Dim m As Match
           Dim strPattern As String = "(?<code>\\[ux][A-F0-9]{2,4})"
           m = Regex.Match(text, strPattern, RegexOptions.IgnoreCase)
           If m.Success Then
               Dim strValue As String
               strValue = m.Groups("code").Value
               Dim digitLength As Integer = strValue.Length - 2
               text = text.Replace(strValue, "")
               Dimint As Integer
               int = System.Int32.Parse(strValue.Substring(2, digitLength), NumberStyles.HexNumber)
               Dim ch As Char = ChrW(int)

               docText.ReplacePattern(strValue, ch)
           Else
               Exit Do
           End If
           If Not text.Length < iLength Then
               Exit Do
           End If
       Loop
       selText.StartOfDocument()
   End Sub
End Module

enjoy it!

posted on 2004-08-31 00:55  birdshome  阅读(11599)  评论(33编辑  收藏  举报

导航