objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");
objhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
objhttp.send(info);
statisticsSuc.asp就是将数据库存入数据库,但是遇到中文就是乱码,看了很多资料,都不知道怎么解决,请教哪位解决的朋友,谢谢了!!!
21 个解决方案
#1
自己顶一下了,救人要紧啊!!:(
#2
感谢FASON,但是,呵呵,还是有问题呢!!怎么会事!
#3
乱吗:娴嬭瘯
#4
再说一下,我把objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");去掉了
我觉得有没有一样!!
我觉得有没有一样!!
#5
数据库中字段的类型.
#6
MSSQL数据库:varchar类型
#7
再顶,就没高手么??!
#8
5555555.没人肯帮我!
#9
通过以下函数转换一下:
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
#10
谢谢楼上的,但你的函数是不是有问题啊!!
不光没解决,反而运行都有问题了!!
不光没解决,反而运行都有问题了!!
#11
有个问题,乱吗总是这样的,注意我的参数+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit
opinstructions就是要传递的中文
结果乱吗总是这样显示"鎵?cardprofit="
为什么会显示出来cardprofit呢??
opinstructions就是要传递的中文
结果乱吗总是这样显示"鎵?cardprofit="
为什么会显示出来cardprofit呢??
#12
哦,对起给错了,
应该是:
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");
objhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
objhttp.send(URLEncoding(info));
应该是:
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");
objhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
objhttp.send(URLEncoding(info));
#13
楼上的,你给的是VBS的,我本身提交页是HTML的啊,也就是JS的啊,
我还以为,在处理数据的页面用你的函数转换呢!!
这些我看了很多帖子了,就是没有JS的,就连孟子老大的,我运行起来,都没对啊!!高手再看看啊!!!
我还以为,在处理数据的页面用你的函数转换呢!!
这些我看了很多帖子了,就是没有JS的,就连孟子老大的,我运行起来,都没对啊!!高手再看看啊!!!
#14
http://blog.csdn.net/net_lover/archive/2002/09/10/6908.aspx
#15
孟老大,我看过你的文章了!!
我运行以后,打印出来的是空值,为什么!!!
<script>
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var s = '<?xml version="1.0"?><a> 如何解决XMLHTTP提交过时返回的是乱码,这是先提交上去,再返回的文字。 </a>'
xmlhttp.open("POST","xmlencode.asp",false)
xmlhttp.setRequestHeader("Content-Type","text/xml")
xmlhttp.send(s)
alert(xmlhttp.responseXML.xml);
</script>
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
Dim varCount,varReq,xmldom
varCount = Request.TotalBytes
varReq = Request.BinaryRead(varCount)
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Set xmldom = Server.CreateObject("MSXML2.DOMDocument")
xmldom.load varReq
Response.Write "<?xml version=""1.0"" encoding=""GB2312""?>" & xmldom.documentElement.xml
End If
%>
因为我只是POST!!,看看哪的问题,还是我理解问题!!
我运行以后,打印出来的是空值,为什么!!!
<script>
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var s = '<?xml version="1.0"?><a> 如何解决XMLHTTP提交过时返回的是乱码,这是先提交上去,再返回的文字。 </a>'
xmlhttp.open("POST","xmlencode.asp",false)
xmlhttp.setRequestHeader("Content-Type","text/xml")
xmlhttp.send(s)
alert(xmlhttp.responseXML.xml);
</script>
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
Dim varCount,varReq,xmldom
varCount = Request.TotalBytes
varReq = Request.BinaryRead(varCount)
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Set xmldom = Server.CreateObject("MSXML2.DOMDocument")
xmldom.load varReq
Response.Write "<?xml version=""1.0"" encoding=""GB2312""?>" & xmldom.documentElement.xml
End If
%>
因为我只是POST!!,看看哪的问题,还是我理解问题!!
#16
而且好象和我的问题有点区别,你是发送一个中文信息
而我的是象FORM表单的发送,总之我也说不清楚,明白我的意思就行,就针对我的问题
直接说明,怎么解决提交过去的中文乱码,拜脱了!!:(
而我的是象FORM表单的发送,总之我也说不清楚,明白我的意思就行,就针对我的问题
直接说明,怎么解决提交过去的中文乱码,拜脱了!!:(
#17
那为什么不用vbs的呢?
#18
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
所有变量在插入前用escape转换一下
cardtype = escape(cardtype);
cardid = escape(cardid);
....
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
所有变量在插入前用escape转换一下
cardtype = escape(cardtype);
cardid = escape(cardid);
....
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
#19
你看这样呢..
<script language="vbscript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
</script>
<script language='javascript'>
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp = new ActiveXObject("Microsoft.XMLHTTP");
info = URLEncoding(info)
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader( "Content-Length",info.length);
objhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
objhttp.send(info);
</script>
<script language="vbscript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
</script>
<script language='javascript'>
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp = new ActiveXObject("Microsoft.XMLHTTP");
info = URLEncoding(info)
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader( "Content-Length",info.length);
objhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
objhttp.send(info);
</script>
#20
TO:to_be_or_not_to_be(to be) (
谢谢,你提醒了我,果然是那样!!!问题解决!!
谢谢,你提醒了我,果然是那样!!!问题解决!!
#21
#1
自己顶一下了,救人要紧啊!!:(
#2
感谢FASON,但是,呵呵,还是有问题呢!!怎么会事!
#3
乱吗:娴嬭瘯
#4
再说一下,我把objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");去掉了
我觉得有没有一样!!
我觉得有没有一样!!
#5
数据库中字段的类型.
#6
MSSQL数据库:varchar类型
#7
再顶,就没高手么??!
#8
5555555.没人肯帮我!
#9
通过以下函数转换一下:
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
#10
谢谢楼上的,但你的函数是不是有问题啊!!
不光没解决,反而运行都有问题了!!
不光没解决,反而运行都有问题了!!
#11
有个问题,乱吗总是这样的,注意我的参数+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit
opinstructions就是要传递的中文
结果乱吗总是这样显示"鎵?cardprofit="
为什么会显示出来cardprofit呢??
opinstructions就是要传递的中文
结果乱吗总是这样显示"鎵?cardprofit="
为什么会显示出来cardprofit呢??
#12
哦,对起给错了,
应该是:
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");
objhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
objhttp.send(URLEncoding(info));
应该是:
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader("Content-Type","text/xml;charset=gb2312");
objhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
objhttp.send(URLEncoding(info));
#13
楼上的,你给的是VBS的,我本身提交页是HTML的啊,也就是JS的啊,
我还以为,在处理数据的页面用你的函数转换呢!!
这些我看了很多帖子了,就是没有JS的,就连孟子老大的,我运行起来,都没对啊!!高手再看看啊!!!
我还以为,在处理数据的页面用你的函数转换呢!!
这些我看了很多帖子了,就是没有JS的,就连孟子老大的,我运行起来,都没对啊!!高手再看看啊!!!
#14
http://blog.csdn.net/net_lover/archive/2002/09/10/6908.aspx
#15
孟老大,我看过你的文章了!!
我运行以后,打印出来的是空值,为什么!!!
<script>
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var s = '<?xml version="1.0"?><a> 如何解决XMLHTTP提交过时返回的是乱码,这是先提交上去,再返回的文字。 </a>'
xmlhttp.open("POST","xmlencode.asp",false)
xmlhttp.setRequestHeader("Content-Type","text/xml")
xmlhttp.send(s)
alert(xmlhttp.responseXML.xml);
</script>
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
Dim varCount,varReq,xmldom
varCount = Request.TotalBytes
varReq = Request.BinaryRead(varCount)
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Set xmldom = Server.CreateObject("MSXML2.DOMDocument")
xmldom.load varReq
Response.Write "<?xml version=""1.0"" encoding=""GB2312""?>" & xmldom.documentElement.xml
End If
%>
因为我只是POST!!,看看哪的问题,还是我理解问题!!
我运行以后,打印出来的是空值,为什么!!!
<script>
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var s = '<?xml version="1.0"?><a> 如何解决XMLHTTP提交过时返回的是乱码,这是先提交上去,再返回的文字。 </a>'
xmlhttp.open("POST","xmlencode.asp",false)
xmlhttp.setRequestHeader("Content-Type","text/xml")
xmlhttp.send(s)
alert(xmlhttp.responseXML.xml);
</script>
<%@ Language=VBScript %>
<%
Response.ContentType = "text/xml"
Response.CharSet = "GB2312"
Dim varCount,varReq,xmldom
varCount = Request.TotalBytes
varReq = Request.BinaryRead(varCount)
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
Set xmldom = Server.CreateObject("MSXML2.DOMDocument")
xmldom.load varReq
Response.Write "<?xml version=""1.0"" encoding=""GB2312""?>" & xmldom.documentElement.xml
End If
%>
因为我只是POST!!,看看哪的问题,还是我理解问题!!
#16
而且好象和我的问题有点区别,你是发送一个中文信息
而我的是象FORM表单的发送,总之我也说不清楚,明白我的意思就行,就针对我的问题
直接说明,怎么解决提交过去的中文乱码,拜脱了!!:(
而我的是象FORM表单的发送,总之我也说不清楚,明白我的意思就行,就针对我的问题
直接说明,怎么解决提交过去的中文乱码,拜脱了!!:(
#17
那为什么不用vbs的呢?
#18
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
所有变量在插入前用escape转换一下
cardtype = escape(cardtype);
cardid = escape(cardid);
....
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
所有变量在插入前用escape转换一下
cardtype = escape(cardtype);
cardid = escape(cardid);
....
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
#19
你看这样呢..
<script language="vbscript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
</script>
<script language='javascript'>
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp = new ActiveXObject("Microsoft.XMLHTTP");
info = URLEncoding(info)
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader( "Content-Length",info.length);
objhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
objhttp.send(info);
</script>
<script language="vbscript">
Function URLEncoding(vstrIn)
strReturn = ""
For i = 1 To Len(vstrIn)
ThisChr = Mid(vStrIn,i,1)
If Abs(Asc(ThisChr)) < &HFF Then
strReturn = strReturn & ThisChr
Else
innerCode = Asc(ThisChr)
If innerCode < 0 Then
innerCode = innerCode + &H10000
End If
Hight8 = (innerCode And &HFF00)\ &HFF
Low8 = innerCode And &HFF
strReturn = strReturn & "%" & Hex(Hight8) & "%" & Hex(Low8)
End If
Next
URLEncoding = strReturn
End Function
</script>
<script language='javascript'>
info="cardtype="+cardtype+"&cardname="+cardid+"&flagid="+flagid+"&cardquantity="+cardquantity+"&cardprice="+cardprice+"&opinstructions="+opinstructions+"&cardprofit="+cardprofit;
objhttp = new ActiveXObject("Microsoft.XMLHTTP");
info = URLEncoding(info)
objhttp.open("post","statisticsSuc.asp",false);
objhttp.setRequestHeader( "Content-Length",info.length);
objhttp.setRequestHeader("CONTENT-TYPE","application/x-www-form-urlencoded");
objhttp.send(info);
</script>
#20
TO:to_be_or_not_to_be(to be) (
谢谢,你提醒了我,果然是那样!!!问题解决!!
谢谢,你提醒了我,果然是那样!!!问题解决!!