以下仅供学习研究之用,不得用于其它用途,未经允许谢绝转载。
'个人代码风格注释(变量名中第一个小写字母表表示变量类型)
'i:为integer型;
's:为string;
function u2utf8(byval a_inum)
dim sresult,sutf8
dim itemp,ihexnum,i
ihexnum = trim(a_inum)
if ihexnum = "" then
exit function
end if
sresult = ""
if (ihexnum < 128) then
sresult = sresult & ihexnum
elseif (ihexnum < 2048) then
sresult = chrb(&h80 + (ihexnum and &h3f))
ihexnum = ihexnum \ &h40
sresult = chrb(&hc0 + (ihexnum and &h1f)) & sresult
elseif (ihexnum < 65536) then
sresult = chrb(&h80 + (ihexnum and &h3f))
ihexnum = ihexnum \ &h40
sresult = chrb(&h80 + (ihexnum and &h3f)) & sresult
ihexnum = ihexnum \ &h40
sresult = chrb(&he0 + (ihexnum and &hf)) & sresult
end if
u2utf8 = sresult
end function
function gb2utf(byval a_sstr)
dim sgb,sresult,stemp
dim ilen,iunicode,itemp,i
sgb = trim(a_sstr)
ilen = len(sgb)
for i = 1 to ilen
stemp = mid(sgb,i,1)
itemp = asc(stemp)
if (itemp>127 or itemp<0) then
iunicode = ascw(stemp)
if iunicode<0 then
iunicode = iunicode + 65536
end if
else
iunicode = itemp
end if
sresult = sresult & u2utf8(iunicode)
next
gb2utf = sresult
end function
'调用方法
response.binarywrite(gb2utf("中国人"))
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器