您的位置:程序门 -> vb -> 非技术类



中文处理的问题..


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


中文处理的问题..[已结贴,结贴人:nsisn]
发表于:2007-04-22 16:05:44 楼主
d1   a9   d2   b8   ce   de   c9   f9=雪夜无声
msgbox   hex2chr( "d1   a9   d2   b8   ce   de   c9   f9 ")
就出问题了...

public   function   hex2chr(byval   hexstr   as   string)
dim   sarr()   as   string
dim   sarr2()   as   string
dim   i   as   long
dim   x   as   long
dim   cal1     as   string
dim   cal2   as   string
sarr()   =   split(ltrim(hexstr),   "   ")
for   i   =   0   to   ubound(sarr())
cal1   =   cal1   &   "   "   &   hextodec(sarr(i))
next   i

sarr2()   =   split(ltrim(cal1),   "   ")
for   x   =   0   to   ubound(sarr2())
cal2   =   cal2   &   chrw(sarr2(x))
next   x
hex2chr   =   cal2
end   function

-   - ¦
如果hex有中文怎么版?
发表于:2007-04-22 16:25:501楼 得分:0
hextodec有吗?
chrw是转换unicode码,你的是unicode吗?
发表于:2007-04-22 16:30:322楼 得分:5


private   sub   command1_click()
msgbox   hex2string( "d1   a9   d2   b8   ce   de   c9   f9 ")
end   sub


private   function   hex2string(byval   shex   as   string,   optional   bunicode   as   boolean)
        dim   sbyte   as   variant
        dim   bychar()   as   byte
        dim   i   as   long
        shex   =   replace(shex,   vbcrlf,   " ")
        sbyte   =   split(shex,   "   ")
        redim   bychar(0   to   ubound(sbyte))   as   byte
        for   i   =   0   to   ubound(sbyte)
                bychar(i)   =   val( "&h "   &   sbyte(i))
        next
        if   bunicode   then
                hex2string   =   bychar
        else
                hex2string   =   strconv(bychar,   vbunicode)
        end   if
end   function


快速检索

最新资讯