'宽字符版替换
Function YF_ReplaceW(Expression As CWSTR, Find As CWSTR, Replacewith As CWSTR) As CWSTR
   Dim As  Long  FF(),fc,i,u,Lf,Le,Lr,Lu,t,pU,pR,pE,pF
   Dim outstr As CWSTR
   Le = Len(Expression)
   Lf = Len(Find)
   Lr = Len(Replacewith)
   If Le = 0 Or Lf = 0 Then
      Return Expression
   Else
      '先找出替换数与位置----------------------------------
      u = -1
      ReDim ff(100)
      i = 1
      Do
         i = InStr(i, **Expression, **Find)
         if i = 0 then exit Do
         u += 1
         If u > UBound(ff) Then ReDim Preserve ff(u + 100)
         ff(u) = i
         i += lf
      Loop

      If u = -1 Then
         Return Expression
      Else
         Lu = Le + (Lr - Lf) * (u + 1)  'Lu=Le - Lf * (u+1) + Lr * (u+1)
         outstr = WSpace(lu)   
         t = 1
         pU = 1
         pE =1
         For i = 0 To u
            Lu = FF(i) - t
            If Lu > 0 Then '复制原字符
               Mid(**outstr,pU ,Lu)=Mid (**Expression,pE ,Lu)
               pU += Lu
            End If
            If Lr > 0 Then '复制替换字符
               Mid(**outstr,pU ,Lr)=Replacewith
               pU += Lr
            End If
            pE += Lu + Lf
            t += Lu + Lf
         Next
         If t <= le Then
            lu = le - t + 1
            Mid(**outstr,pU ,Lu)=Mid (**Expression,pE ,Lu)
         End If
         Return outstr
      End If
   End If
End Function