仓酷云

标题: ASP网页设计ASP中汉字与UTF-8的相互转换 [打印本页]

作者: 柔情似水    时间: 2015-1-16 22:12
标题: ASP网页设计ASP中汉字与UTF-8的相互转换
国内有些大的CRM厂商的ASP就写得不错.无论是概念还是它里面用JAVASCRIPT的能力.并不是说现在的程序员用了ASP.NET来写程序就可以说自己高档了汉字|转换=============汉字转换为UTF-8==================
functionchinese2unicode(Str)
fori=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
chinese2unicode=Str_unicode
endfunction
=============UTF-8转换为汉字==================
functionUTF2GB(UTFStr)
forDig=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
endfunction

functionConvChinese(x)
A=split(mid(x,2),"%")
i=0
j=0
fori=0toubound(A)
A(i)=c16to2(A(i))
next
fori=0toubound(A)-1
DigS=instr(A(i),"0")
Unicode=""
forj=1toDigS-1
ifj=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
endfunction
functionc2to16(x)
i=1
fori=1tolen(x)step4
c2to16=c2to16&hex(c2to10(mid(x,i,4)))
next
endfunction
functionc2to10(x)
c2to10=0
ifx="0"thenexitfunction
i=0
fori=0tolen(x)-1
ifmid(x,len(x)-i,1)="1"thenc2to10=c2to10+2^(i)
next
endfunction
functionc16to2(x)
i=0
fori=1tolen(trim(x))
tempstr=c10to2(cint(int("&h"&mid(x,i,1))))
dowhilelen(tempstr)<4
tempstr="0"&tempstr
loop
c16to2=c16to2&tempstr
next
endfunction
functionc10to2(x)
mysign=sgn(x)
x=abs(x)
DigS=1
do
ifx<2^DigSthen
exitdo
else
DigS=DigS+1
endif
loop
tempnum=x
i=0
fori=DigSto1step-1
iftempnum>=2^(i-1)then
tempnum=tempnum-2^(i-1)
c10to2=c10to2&"1"
else
c10to2=c10to2&"0"
endif
next
ifmysign=-1thenc10to2="-"&c10to2
endfunction
楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。
作者: 冷月葬花魂    时间: 2015-1-18 22:54
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。
作者: admin    时间: 2015-1-24 12:06
下面简单介绍一下我学习ASP的方法,希望对想学习ASP的朋友有所帮助...
作者: 小魔女    时间: 2015-2-7 03:41
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
作者: 老尸    时间: 2015-2-20 11:52
Response:从字面上讲是“响应”,因此这个是服务端向客户端发送东西的,例如Response.Write
作者: 莫相离    时间: 2015-3-6 17:36
那么,ASP.Net有哪些改进呢?
作者: 因胸联盟    时间: 2015-3-13 05:08
另外因为asp需要使用组件,所以了解一点组件的知识(ADODB也是组件)
作者: 蒙在股里    时间: 2015-3-20 13:37
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2