从HttpRequest收到的请求中含有中文字符,但是编码是unicode的,需要转换为GB2312才可以看到中文,否则是如%7C%B2%E2%CA%D4%09%09%之类的编码,请问该怎样转换??
解决方案 »
- ajax的dropdown四级连动的问题
- 我建立了一个window服务,不知道为什么运行一段时间后,服务就不运行程序了.
- 求助,.net 2005中用javascript增加新行后,可以显示,但是立即就会消失
- 超链接的文字说明+链接打开确定大小和样式页面-ASP教程,ASP应用
- 如何用服务器端控件实现类似HTML4.0中的元素optgroup
- JS鼠标移走还选中如何实现?
- 急,这问题到底怎么解决!!
- 对session赋值和修改
- ajax 如何访问本页面的方法
- 想到一个问题:ASP.NET怎么在客户端加判断框?欢迎讨论
- 要计算机运行效率还是要人编写代码的效率?
- 通过浏览器下载aspx源文件的问题
{
if ((des.IndexOf("%u")>0)||(des.IndexOf("?")<0))
return des;
else
{
string resultDes = "";
string temp = "";
resultDes = des.Substring(0,des.IndexOf("?")+1);
temp = des.Substring(des.IndexOf("?")+1); temp = temp+"&";
while (temp.IndexOf("&")>0)
{
string firstDz = temp.Substring(0,temp.IndexOf("&"));
temp = temp.Substring(temp.IndexOf("&")+1); if (firstDz.IndexOf("=")<0)
continue;
resultDes += firstDz.Substring(0,firstDz.IndexOf("=")+1);
resultDes += System.Web.HttpUtility.UrlEncodeUnicode(firstDz.Substring(firstDz.IndexOf("=")+1))+"&";
}
resultDes = resultDes.Substring(0,resultDes.Length-1);
return resultDes;
}
}
源字符为%7C%B2%E2%CA%D4%09%09%09%09%09&submit=%CC%E1%BD%BB
用了你的方法,返回:
%7C+%B2%E2%CA%D4%B2%E2%CA%D4%BF%C9%09%09%09%09%09&submit=%CC%
这是为什么??
<!--<pages validateRequest="false"/>-->
<httpRuntime
maxRequestLength="20000"
/>
Stream stream=Request.InputStream;
StreamReader sr=new StreamReader(stream,Encoding.UTF8);
string ss=sr.ReadToEnd();
byte[] bs=Encoding.UTF8.GetBytes(ss);
string cc=HttpUtility.UrlDecode(bs,0,bs.Length,Encoding.GetEncoding("GB2312"));