苏州域名注册知识
网站策划、网络推广
网站建设、网站制作设计
网站优化、SEO排名优化
SEO培训、SEO教程
整站优化、整站SEO推广
网站推广、网络营销
关键词优化、关键词排名
域名主机、企业邮箱
苏州网站建设业务范围
苏州网站建设知识库大全
· 如何才能避免SEO网站被复制或
· 哪些方法技巧有利于网站SEO快
· 凤巢网络总结常见的移动端SEO
· 搜索引擎SEO优化是否对于女性
· 分析营销型手机网站seo优化具
· 选对SEO外包公司对于企业网站
· 公司网站SEO优化过程中如何确
· 南京网站优化SEO需要注意的一
· 怎么样的SEO文章才能带来精准
· 想成为SEO大牛级别的人物需要
苏州网站建设常见问题
常见问题
关于UTF-8和GB2312表单的问题的解答

公司关于UTF-8和GB2312表单的问题的解答,有时候我们经常遇到在不同编码的页面上使用表单提交信息出现中文乱码的情况。
在提交表单时,使用JS控制进行提交,例如表单如下:
解决方法如下:
1、utf-8向gb2312提交表单成乱码

2、gb2312向utf-8提交表单成乱码<%
用途:將utf-8編碼漢字轉換為gb2312碼,兼容英文和數字
版權:雖說是原創,其實也參考了別人的部分算法
用法:response.write utf2gb("%e9%83%bd%e5%b8%82%e6%83%85%e7%b7%a3 %e6%98%9f%e5%ba%a7")


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
if j=1 then
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)
end if
next

if len(c2to16(unicode))=4 then
convchinese=convchinese & chrw(int("&h" & c2to16(unicode)))
else
convchinese=convchinese & chr(int("&h" & c2to16(unicode)))
end if
next
end function

function c2to16(x)
i=1
for i=1 to len(x) step 4
c2to16=c2to16 & hex(c2to10(mid(x,i,4)))
next
end function

function c2to10(x)
c2to10=0
if x="0" then exit function
i=0
for i= 0 to len(x) -1
if mid(x,len(x)-i,1)="1" then c2to10=c2to10+2^(i)
next
end function

function c16to2(x)
i=0
for i=1 to len(trim(x))
tempstr= c10to2(cint(int("&h" & mid(x,i,1))))
do while len(tempstr)<4
tempstr="0" & tempstr
loop
c16to2=c16to2 & tempstr
next
end function

function c10to2(x)
mysign=sgn(x)
x=abs(x)
digs=1
do
if x<2^digs then
exit do
else
digs=digs+1
end if
loop
tempnum=x

i=0
for i=digs to 1 step-1
if tempnum>=2^(i-1) then
tempnum=tempnum-2^(i-1)
c10to2=c10to2 & "1"
else
c10to2=c10to2 & "0"
end if
next
if mysign=-1 then c10to2="-" & c10to2
end function
%>

汉字转换为UTF-8

Function chinese2unicode()
 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
 Response.Write Str_unicode
end function

发布时间:2012-05-08 12:08:14 点击率:1927 返回上一页
公司地址: 苏州市高新区浩福路1号维田商务中心3楼
垂询热线: 13771728337
公司邮箱: sales@jsfengchao.com
客服在线: 点击这里给我发消息
2018年 抓住网络营销火爆之年
下一个成功故事的主角就是您
一切为您提高成效
足不出户 营销全球
凤巢网络全体员工用心为您服务
祝您新年快乐
主营业务:苏州网站建设 苏州网站制作 苏州网站优化 苏州网络公司 苏州SEO优化 苏州做网站 苏州网络推广 苏州网站建设公司 苏州网站制作公司 苏州百度推广 苏州网站设计