6 个解决方案
#1
<%
Session.CodePage=936
s=Request("s")
Session.CodePage=65001
Response.Charset="utf-8"
Response.Write s
%>
Session.CodePage=936
s=Request("s")
Session.CodePage=65001
Response.Charset="utf-8"
Response.Write s
%>
#2
pass by
#3
如果是接收的话用escape和unescape
用JAVASCRIPT语法格式。
忽忽。。
用JAVASCRIPT语法格式。
忽忽。。
#4
楼上能举个例子吗? 我把我代码贴出来 大家一起分析 现在就差取回结果是乱码!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%response.buffer=true%>
<% Response.ContentType="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta http-equiv='Cache-Control' content='no-cache'/></head>
<card title='翻译'>
<p>
<%
Dim lang,domain,text,method
lang = Request.QueryString("lang")
domain="00"
text=request("text")
if trim(text)<>"" then
Set RegExpObj=new RegExp
RegExpObj.Pattern="^[\u4e00-\u9fa5]+$"
ReGCheck=RegExpObj.test(text)
Set RegExpObj=nothing
if ReGCheck then
lang="02"
else
lang="01"
end if
UTF2gb(text)
Dim Url,Html,results
Url="http://220.194.55.28/cgi-bin/text.cgi"
param="lang="&lang&"&domain="&domain&"&text="&text&""
Html = getHTTPPage(Url)
length=Instr(Html,":</b><br>")
Html=trim(mid(Html,length+9))
response.write("翻译结果:")
Response.Charset="utf-8"
response.write(Html)
else
end if
%>
<br/>
请选择您需要的服务:<br/>
<select name="lang" id="lang">
<option value="01">英译汉</option>
<option value="02">汉译英</option>
</select><br/>
需要翻译的内容:<br/>
<input type="text" name="text" emptyok="false" title="内容"/><br/>
<anchor>提交<go href="wap.asp" method="post">
<postfield name="lang" value="$(lang)"/>
<postfield name="text" value="$(text)"/></go></anchor>
<br/>
--------------<br/>
<!--#include file="../inc/gdcmccback_index.asp"-->
<!--#include file="../inc/gdcmccback.asp"-->
</p>
</card>
</wml>
<%
Function getHTTPPage(url)
dim objXML
set objXML=Server.CreateObject("MSXML2.XMLHTTP.5.0") '定义
objXML.open "POST",url,false'打开
objXML.send(param)'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
results=objXML.responseBody
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "UTF-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
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
text=Str_unicode
end function
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
text=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
function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%response.buffer=true%>
<% Response.ContentType="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta http-equiv='Cache-Control' content='no-cache'/></head>
<card title='翻译'>
<p>
<%
Dim lang,domain,text,method
lang = Request.QueryString("lang")
domain="00"
text=request("text")
if trim(text)<>"" then
Set RegExpObj=new RegExp
RegExpObj.Pattern="^[\u4e00-\u9fa5]+$"
ReGCheck=RegExpObj.test(text)
Set RegExpObj=nothing
if ReGCheck then
lang="02"
else
lang="01"
end if
UTF2gb(text)
Dim Url,Html,results
Url="http://220.194.55.28/cgi-bin/text.cgi"
param="lang="&lang&"&domain="&domain&"&text="&text&""
Html = getHTTPPage(Url)
length=Instr(Html,":</b><br>")
Html=trim(mid(Html,length+9))
response.write("翻译结果:")
Response.Charset="utf-8"
response.write(Html)
else
end if
%>
<br/>
请选择您需要的服务:<br/>
<select name="lang" id="lang">
<option value="01">英译汉</option>
<option value="02">汉译英</option>
</select><br/>
需要翻译的内容:<br/>
<input type="text" name="text" emptyok="false" title="内容"/><br/>
<anchor>提交<go href="wap.asp" method="post">
<postfield name="lang" value="$(lang)"/>
<postfield name="text" value="$(text)"/></go></anchor>
<br/>
--------------<br/>
<!--#include file="../inc/gdcmccback_index.asp"-->
<!--#include file="../inc/gdcmccback.asp"-->
</p>
</card>
</wml>
<%
Function getHTTPPage(url)
dim objXML
set objXML=Server.CreateObject("MSXML2.XMLHTTP.5.0") '定义
objXML.open "POST",url,false'打开
objXML.send(param)'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
results=objXML.responseBody
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "UTF-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
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
text=Str_unicode
end function
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
text=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
function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
#5
。。。迷糊。
是小偷程序么?
如果是直接用responseBody获取
然后用这个转
JavaScript语法格式
var Content = replContent(Content, "gb2312");
function replContent(Content, CharCode) {
//编码转换
var obj = Server.CreateObject("Adodb.Stream");
with (obj) {
Type = 1;
Mode = 3;
Open();
Write(Content);
Position = 0;
Type = 2;
CharSet = CharCode;
var nString = ReadText;
Close;
}
obj = null;
return nString;
}
VBScript语法格式.
Dim nString
nString = replContent(.ResponseBody, "gb2312")
Function replContent(Content, CharCode)
Set obj = Server.CreateObject("Adodb.Stream")
With obj
.Type = 1
.Mode = 3
.Open()
.Write(Content)
.Position = 0
.Type = 2
.CharSet = CharCode
Dim nString
nString = .ReadText
.Close
End With
Set obj = Nothing
replContent = nString
End Function
如果是调用的本地的文件的话那么就传数据的时候都用escape转下。
然后获取数据的时候用unescape转回来。
这样就没有问题了。
是小偷程序么?
如果是直接用responseBody获取
然后用这个转
JavaScript语法格式
var Content = replContent(Content, "gb2312");
function replContent(Content, CharCode) {
//编码转换
var obj = Server.CreateObject("Adodb.Stream");
with (obj) {
Type = 1;
Mode = 3;
Open();
Write(Content);
Position = 0;
Type = 2;
CharSet = CharCode;
var nString = ReadText;
Close;
}
obj = null;
return nString;
}
VBScript语法格式.
Dim nString
nString = replContent(.ResponseBody, "gb2312")
Function replContent(Content, CharCode)
Set obj = Server.CreateObject("Adodb.Stream")
With obj
.Type = 1
.Mode = 3
.Open()
.Write(Content)
.Position = 0
.Type = 2
.CharSet = CharCode
Dim nString
nString = .ReadText
.Close
End With
Set obj = Nothing
replContent = nString
End Function
如果是调用的本地的文件的话那么就传数据的时候都用escape转下。
然后获取数据的时候用unescape转回来。
这样就没有问题了。
#6
谢谢楼上 问题一楼已经帮忙解决了 这是WAP页面 所以脚本尽量不用
#1
<%
Session.CodePage=936
s=Request("s")
Session.CodePage=65001
Response.Charset="utf-8"
Response.Write s
%>
Session.CodePage=936
s=Request("s")
Session.CodePage=65001
Response.Charset="utf-8"
Response.Write s
%>
#2
pass by
#3
如果是接收的话用escape和unescape
用JAVASCRIPT语法格式。
忽忽。。
用JAVASCRIPT语法格式。
忽忽。。
#4
楼上能举个例子吗? 我把我代码贴出来 大家一起分析 现在就差取回结果是乱码!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%response.buffer=true%>
<% Response.ContentType="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta http-equiv='Cache-Control' content='no-cache'/></head>
<card title='翻译'>
<p>
<%
Dim lang,domain,text,method
lang = Request.QueryString("lang")
domain="00"
text=request("text")
if trim(text)<>"" then
Set RegExpObj=new RegExp
RegExpObj.Pattern="^[\u4e00-\u9fa5]+$"
ReGCheck=RegExpObj.test(text)
Set RegExpObj=nothing
if ReGCheck then
lang="02"
else
lang="01"
end if
UTF2gb(text)
Dim Url,Html,results
Url="http://220.194.55.28/cgi-bin/text.cgi"
param="lang="&lang&"&domain="&domain&"&text="&text&""
Html = getHTTPPage(Url)
length=Instr(Html,":</b><br>")
Html=trim(mid(Html,length+9))
response.write("翻译结果:")
Response.Charset="utf-8"
response.write(Html)
else
end if
%>
<br/>
请选择您需要的服务:<br/>
<select name="lang" id="lang">
<option value="01">英译汉</option>
<option value="02">汉译英</option>
</select><br/>
需要翻译的内容:<br/>
<input type="text" name="text" emptyok="false" title="内容"/><br/>
<anchor>提交<go href="wap.asp" method="post">
<postfield name="lang" value="$(lang)"/>
<postfield name="text" value="$(text)"/></go></anchor>
<br/>
--------------<br/>
<!--#include file="../inc/gdcmccback_index.asp"-->
<!--#include file="../inc/gdcmccback.asp"-->
</p>
</card>
</wml>
<%
Function getHTTPPage(url)
dim objXML
set objXML=Server.CreateObject("MSXML2.XMLHTTP.5.0") '定义
objXML.open "POST",url,false'打开
objXML.send(param)'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
results=objXML.responseBody
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "UTF-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
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
text=Str_unicode
end function
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
text=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
function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%response.buffer=true%>
<% Response.ContentType="text/vnd.wap.wml" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta http-equiv='Cache-Control' content='no-cache'/></head>
<card title='翻译'>
<p>
<%
Dim lang,domain,text,method
lang = Request.QueryString("lang")
domain="00"
text=request("text")
if trim(text)<>"" then
Set RegExpObj=new RegExp
RegExpObj.Pattern="^[\u4e00-\u9fa5]+$"
ReGCheck=RegExpObj.test(text)
Set RegExpObj=nothing
if ReGCheck then
lang="02"
else
lang="01"
end if
UTF2gb(text)
Dim Url,Html,results
Url="http://220.194.55.28/cgi-bin/text.cgi"
param="lang="&lang&"&domain="&domain&"&text="&text&""
Html = getHTTPPage(Url)
length=Instr(Html,":</b><br>")
Html=trim(mid(Html,length+9))
response.write("翻译结果:")
Response.Charset="utf-8"
response.write(Html)
else
end if
%>
<br/>
请选择您需要的服务:<br/>
<select name="lang" id="lang">
<option value="01">英译汉</option>
<option value="02">汉译英</option>
</select><br/>
需要翻译的内容:<br/>
<input type="text" name="text" emptyok="false" title="内容"/><br/>
<anchor>提交<go href="wap.asp" method="post">
<postfield name="lang" value="$(lang)"/>
<postfield name="text" value="$(text)"/></go></anchor>
<br/>
--------------<br/>
<!--#include file="../inc/gdcmccback_index.asp"-->
<!--#include file="../inc/gdcmccback.asp"-->
</p>
</card>
</wml>
<%
Function getHTTPPage(url)
dim objXML
set objXML=Server.CreateObject("MSXML2.XMLHTTP.5.0") '定义
objXML.open "POST",url,false'打开
objXML.send(param)'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
results=objXML.responseBody
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = "UTF-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
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
text=Str_unicode
end function
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
text=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
function isvalidhex(str)
isvalidhex=true
str=ucase(str)
if len(str)<>3 then isvalidhex=false:exit function
if left(str,1)<>"%" then isvalidhex=false:exit function
c=mid(str,2,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
c=mid(str,3,1)
if not (((c>="0") and (c<="9")) or ((c>="A") and (c<="Z"))) then isvalidhex=false:exit function
end function
%>
#5
。。。迷糊。
是小偷程序么?
如果是直接用responseBody获取
然后用这个转
JavaScript语法格式
var Content = replContent(Content, "gb2312");
function replContent(Content, CharCode) {
//编码转换
var obj = Server.CreateObject("Adodb.Stream");
with (obj) {
Type = 1;
Mode = 3;
Open();
Write(Content);
Position = 0;
Type = 2;
CharSet = CharCode;
var nString = ReadText;
Close;
}
obj = null;
return nString;
}
VBScript语法格式.
Dim nString
nString = replContent(.ResponseBody, "gb2312")
Function replContent(Content, CharCode)
Set obj = Server.CreateObject("Adodb.Stream")
With obj
.Type = 1
.Mode = 3
.Open()
.Write(Content)
.Position = 0
.Type = 2
.CharSet = CharCode
Dim nString
nString = .ReadText
.Close
End With
Set obj = Nothing
replContent = nString
End Function
如果是调用的本地的文件的话那么就传数据的时候都用escape转下。
然后获取数据的时候用unescape转回来。
这样就没有问题了。
是小偷程序么?
如果是直接用responseBody获取
然后用这个转
JavaScript语法格式
var Content = replContent(Content, "gb2312");
function replContent(Content, CharCode) {
//编码转换
var obj = Server.CreateObject("Adodb.Stream");
with (obj) {
Type = 1;
Mode = 3;
Open();
Write(Content);
Position = 0;
Type = 2;
CharSet = CharCode;
var nString = ReadText;
Close;
}
obj = null;
return nString;
}
VBScript语法格式.
Dim nString
nString = replContent(.ResponseBody, "gb2312")
Function replContent(Content, CharCode)
Set obj = Server.CreateObject("Adodb.Stream")
With obj
.Type = 1
.Mode = 3
.Open()
.Write(Content)
.Position = 0
.Type = 2
.CharSet = CharCode
Dim nString
nString = .ReadText
.Close
End With
Set obj = Nothing
replContent = nString
End Function
如果是调用的本地的文件的话那么就传数据的时候都用escape转下。
然后获取数据的时候用unescape转回来。
这样就没有问题了。
#6
谢谢楼上 问题一楼已经帮忙解决了 这是WAP页面 所以脚本尽量不用