例子如下:
XMLHTTP myxml=new XMLHTTP();
myxml.open("POST","http://aa/myabc/aa.asp",false,"","");
string str="login=aaa;pass=bbb";
myxml.setRequestHeader("content-length",str.Length.ToString());
myxml.setRequestHeader("content-type","application/x-www-form-urlencoded");
myxml.send(str);
Response.write(myxml.ResponseText)
的内容是乱码,其实在ASP里也有出现类似的问题,但是用了一个函数:
Function GetBytes2BSTR(p_sHtmlStr)
dim sReturnStr
dim i,n sReturnStr = ""
n = LenB(p_sHtmlStr) For i = 1 To n
dim sCharCode
dim sNextCharCode sCharCode = AscB( MidB(p_sHtmlStr, i, 1) ) If (sCharCode < &H80) Then
sReturnStr = sReturnStr & Chr(sCharCode)
Else
sNextCharCode = AscB( MidB(p_sHtmlStr, i+1, 1) )
sReturnStr = sReturnStr & Chr(CLng(sCharCode) * &H100 + CInt(sNextCharCode))
i = i + 1
End If
Next GetBytes2BSTR = sReturnStr
End Function
将其进行转换,使之变正常的文字,但在C#里就不知怎么转换了
XMLHTTP myxml=new XMLHTTP();
myxml.open("POST","http://aa/myabc/aa.asp",false,"","");
string str="login=aaa;pass=bbb";
myxml.setRequestHeader("content-length",str.Length.ToString());
myxml.setRequestHeader("content-type","application/x-www-form-urlencoded");
myxml.send(str);
Response.write(myxml.ResponseText)
的内容是乱码,其实在ASP里也有出现类似的问题,但是用了一个函数:
Function GetBytes2BSTR(p_sHtmlStr)
dim sReturnStr
dim i,n sReturnStr = ""
n = LenB(p_sHtmlStr) For i = 1 To n
dim sCharCode
dim sNextCharCode sCharCode = AscB( MidB(p_sHtmlStr, i, 1) ) If (sCharCode < &H80) Then
sReturnStr = sReturnStr & Chr(sCharCode)
Else
sNextCharCode = AscB( MidB(p_sHtmlStr, i+1, 1) )
sReturnStr = sReturnStr & Chr(CLng(sCharCode) * &H100 + CInt(sNextCharCode))
i = i + 1
End If
Next GetBytes2BSTR = sReturnStr
End Function
将其进行转换,使之变正常的文字,但在C#里就不知怎么转换了
解决方案 »
- sqldatareader使用不当会使网站出现异常
- 请问我想做个根据访问者ip范围,显示属于该范围的Ip的在线情况
- vs开发的项目怎么样发布到互联网
- This.SetAll("DynamicBackColor","IIF(DELE(),rgb(255,0,0),rgb(255,255,255))", "Col
- 一个关于sql数据库的问题,希望大家帮我解决!
- 大家给推荐一些关于组件开发的教程或文章!: )
- 我想在在Datagrid上面移动鼠标时,能看到自定义的提示。不知如何实现。象进入163邮箱时的前面提示,很漂亮的。
- 难题!如何从服务器端下载文件到指定路径的客户端而不出现下载对话框?
- 请问VS2010 SQL2008适合在win7下安装呢还是XP啊
- 为什么ACCESS数据只能SELECT而不能INSERT呢?
- 昨天的问题还没解决!大家帮帮忙吧
- datagrid的datasource指定为datareader时出错,为什么
客户端解码:
var u64='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
var f1=u64.substr(0,16);
var f2=u64.substr(16,16);
var f3=u64.substr(32,16);
function LostinetEncode(str)
{
var res='';
var len=str.length;
for(var i=0;i<len;i++)
{
var cc=str.charCodeAt(i);
if(cc<256)
{
if(i+1<len)
{
var ccnext=str.charCodeAt(i+1);
if(ccnext<256)
{
i++;
cc+=ccnext*256;
res+=f3.charAt(cc%16)+u64.charAt((cc>>4)%64)+u64.charAt((cc>>10)%64);
continue;
}
}
res+=f2.charAt(cc%16)+f2.charAt(cc>>4);
}
else
{
res+=f1.charAt(cc%16)+u64.charAt((cc>>4)%64)+u64.charAt((cc>>10)%64);
}
}
return res;
}
服务器端解码:
static string u64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static string f1="ABCDEFGHIJKLMNOP";
static string f2="QRSTUVWXYZabcdef";
static string f3="ghijklmnopqrstuv";
static string LostinetDecode(string str)
{
if(str==null) return "";
StringBuilder sb=new StringBuilder();
int len=str.Length;
int cc1,cc2,cc3;
for(int i=0;i<len;i++)
{
char fc=str[i];
cc1=f1.IndexOf(fc);
if(cc1>-1)
{
cc2=u64.IndexOf(str[++i]);
cc3=u64.IndexOf(str[++i]);
sb.Append( (char)(cc1+cc2*16+cc3*1024) );
}
else
{
cc1=f2.IndexOf(fc);
if(cc1>-1)
{
cc2=f2.IndexOf(str[++i]);
sb.Append( (char)(cc1+cc2*16) );
}
else
{
cc1=f3.IndexOf(fc);
cc2=u64.IndexOf(str[++i]);
cc3=u64.IndexOf(str[++i]);
int ccx=cc1+cc2*16+cc3*1024;
sb.Append( (char)(ccx%256) );
sb.Append( (char)(ccx>>8) );
}
}
}
return sb.ToString();
}再详细点,请参考Lostinet兄的Janc