在vbs中迭代unicode

时间:2014-01-13 18:22:31

标签: unicode vbscript

我需要将重音字母转换为常规对应字母,即À到A.我计划使用一长串替换语句,例如

orig_string = Replace(orig_string, "Ã", "a", 1, -1, vbTextCompare)  

或某种类型的数组来完成同样的事情。我试图在我的访问vb编辑器中粘贴一个字符列表áàâäãåǻăāąấấặắảạḁầẫẩậằẵẳ但是得到了áàâäãå?????????????????。话虽如此,我想尝试使用

的内容
Function convert_unicode(sIn As String) As String
    Dim r As New RegExp, a_patern As String
    Dim colMatches As MatchCollection

    Debug.Print sIn

    **For a_patern = "\u00C0" To "\u00C5" <-pseudo code**
        With r
            .Pattern = a_patern
            .IgnoreCase = True
            .Global = True
            .MultiLine = False
            convert_unicode = .Replace(sIn, "A")
        End With
    Next a_patern

   **For a_patern = "\u00C8" To "\u00CB"  <-pseudo code**
        With r
            .Pattern = a_patern
            .IgnoreCase = True
            .Global = True
            .MultiLine = False
            convert_unicode = .Replace(sIn, "B")
        End With
    Next a_patern

    Debug.Print convet_unicode
End Function

1 个答案:

答案 0 :(得分:0)

替换循环可能看起来像这样:

s = "..."

For u = &h00c0 To &h00c5
  s = Replace(s, ChrW(u), "A")
Next

ChrW函数将字符代码转换为(宽/ Unicode)字符。