我用下面的代码在Win2000英文平台下处理简体汉字,总是出错。
mStr = StrConv(src, vbFromUnicode)
......
Code = StrConv(mStr, vbUnicode)
改用以下代码后,在Win2000简体中文平台下处理,OK;但切换到英文平台时,还是出错,
为什么,有没有比较多平台下通用的处理方案?
mStr = StrConv(src, vbFromUnicode, &H804)
......
Code = StrConv(mStr, vbUnicode, &H804)

解决方案 »

  1.   

    vbFromUnicode是将字符串由 Unicode 转成系统的缺省码页,英文平台的缺省代码页是英文的,如果字符串里有汉字肯定不行了~~
      

  2.   

    public function MakeLen(str as string) as long
    dim c as string 
    dim n as long
       For j = 1 To len(str)
           c = Asc(Mid(str, j, 1))
           If c >= 0 And c < 128 Then
               n = n + 1 '计算英文
           Else
               n = n + 2 '计算中文
           End If
       Next j
       makelen=n
    end sub