UTF-8 Unicode Ansi 汉字GB2321几种编码转换程序(3)
End If
Else
sResult = sResult & Mid(s,i,1)
End If
Else
sResult = sResult & Mid(s,i,1)
End If
Next
DeCodeAnsi = sResult
End Function
</script>
符合BAIDU的UTF-8编码
<p>
汉字 经过 AnsiCode 变为
<%=AnsiCode("汉字")%>
</p>
<p>
%BA%BA%D7%D6 经过 DeCodeAnsi 变为
<%=DeCodeAnsi("%BA%BA%D7%D6 ")%>
</p>
<%
'汉字转换为UTF-8
function chinese2unicode(Str)
dim i
dim Str_one
dim Str_unicode
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 To GB2312
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),"%")
内容版权声明:除非注明,否则皆为本站原创文章。