日期:2010-06-08  浏览次数:20881 次

=============汉字转换为UTF-8==================

function chinese2unicode(Str)
        for i=1 to len(Str) 
                Str_one=Mid(Str,i,1) 
                Str_unicode=Str_unicode&chr(38) 
                Str_unicode=Str_unicode&chr(35) 
                Str_unicode=Str_unicode&chr(120) 
                Str_unicode=Str_unicode& Hex(ascw(Str_one)) 
                Str_unicode=Str_unicode&chr(59) 
        next 
        chinese2unicode = Str_unicode
end function

=============UTF-8转换为汉字==================

function UTF2GB(UTFStr)
        for Dig=1 to len(UTFStr)
                if mid(UTFStr,Dig,1)="%" then
                        if len(UTFStr) >= Dig+8 then
                                GBStr=GBStr & ConvChinese(mid(UTFStr,Dig,9))
                                Dig=Dig+8
                        else
                                GBStr=GBStr & mid(UTFStr,Dig,1)
                        end if
                else
                        GBStr=GBStr & mid(UTFStr,Dig,1)
                end if
        next
        UTF2GB=GBStr
end function


function ConvChinese(x) 
        A=split(mid(x,2),"%")
        i=0
        j=0

        for i=0 to ubound(A) 
                A(i)=c16to2(A(i))
        next

        for i=0 to ubound(A)-1
                DigS=instr(A(i),"0")
                 Unicode=""
                for j=1 to DigS-1
              &