Function chinese2unicode()function chinese2unicode(Str) dim i dim Str_one dim Str_unicode for i=1tolen(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 Response.Write Str_unicode end function
UTF-8 To GB2312
Function UTF2GB()function UTF2GB(UTFStr) for Dig=1tolen(UTFStr) ifmid(UTFStr,Dig,1)="%"then iflen(UTFStr) >= Dig+8then GBStr=GBStr & ConvChinese(mid(UTFStr,Dig,9)) Dig=Dig+8 else GBStr=GBStr &mid(UTFStr,Dig,1) endif else GBStr=GBStr &mid(UTFStr,Dig,1) endif next UTF2GB=GBStr end function Function ConvChinese()function ConvChinese(x) A=split(mid(x,2),"%") i=0 j=0 for i=0toubound(A) A(i)=c16to2(A(i)) next for i=0toubound(A)-1 DigS=instr(A(i),"0") Unicode="" for j=1to DigS-1 if j=1then A(i)=right(A(i),len(A(i))-DigS) Unicode=Unicode& A(i) else i=i+1 A(i)=right(A(i),len(A(i))-2) Unicode=Unicode& A(i) endif next iflen(c2to16(Unicode))=4then ConvChinese=ConvChinese &chrw(int("&H"& c2to16(Unicode))) else ConvChinese=ConvChinese &chr(int("&H"& c2to16(Unicode))) endif next end function Function c2to16()function c2to16(x) i=1 for i=1tolen(x) step4 c2to16=c2to16 &hex(c2to10(mid(x,i,4))) next end function Function c2to10()function c2to10(x) c2to10=0 if x="0"thenexit function i=0 for i=0tolen(x) -1 ifmid(x,len(x)-i,1)="1"then c2to10=c2to10+2^(i) next end function Function c16to2()function c16to2(x) i=0 for i=1tolen(trim(x)) tempstr= c10to2(cint(int("&h"&mid(x,i,1)))) dowhilelen(tempstr)<4 tempstr="0"& tempstr loop c16to2=c16to2 & tempstr next end function Function c10to2()function c10to2(x) mysign=sgn(x) x=abs(x) DigS=1 do if x<2^DigS then exitdo else DigS=DigS+1 endif loop tempnum=x i=0 for i=DigS to1step-1 if tempnum>=2^(i-1) then tempnum=tempnum-2^(i-1) c10to2=c10to2 &"1" else c10to2=c10to2 &"0" endif next if mysign=-1then c10to2="-"& c10to2 end function
posted on
2006-03-11 14:32竹子
阅读(4164)
评论(0)
编辑收藏举报