如何将GB2312转换成UTF8 原来的页面是gb2312的后台加了个论坛是utf8的结果原来页面传递过去后的代码是乱码怎么解决 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在webconfig中配置一下就可以 了 <globalization requestEncoding="utf-8" responseEncoding="utf-8"/> 做成2个站点,原来的一个域名,论坛单独一个域名然后各自使用各自的编码方案,这个不会有冲突的http://www.***.comhttp://bbs.***.com 一鹤 文件播种机把你们gb2312的文件全部转换成utf-8的再改web.config 光改web.config是不行的要把gb2314转成urf8 不能批量转就用文件另存为urf8 各位我不知要转编码而是原来页面提交一个有中文的数据到新页面结果显示是乱码现在我想要的是怎么转换这个数据才能正常显示我试过这个不行 /// <summary> /// 从一种编码到另一种编码 /// </summary> /// <param name="str">源字符串</param> /// <param name="From">From</param> /// <param name="To">To</param> /// <returns></returns> string ConertStr(string str, string From, string To) { byte[] bs = System.Text.Encoding.GetEncoding(From).GetBytes(str); bs = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding(From), System.Text.Encoding.GetEncoding(To), bs); string res = System.Text.Encoding.GetEncoding(To).GetString(bs); return res; } 在获得传递过来的数据后,加上.getBytes("utf-8").toString()如:request.getParameter("").getBytes("utf-8").toString(); 我个人觉得中文URL传递,乱码问题无法解决.用中文传值始终都会有问题出现 楼上的,这么说就不对了!中文乱码问题是普遍存在,但是都是可以解决的!而且有多种解决方法,楼主想要的获得后再转换就是可行的!在获得传递过来的数据后,加上.getBytes("utf-8").toString() 如:request.getParameter("").getBytes("utf-8").toString();确实是有用!至于你所谓的,在转换之前已经不是原始数据了!这我也不知道该怎么解释!一个数据无论怎么传递,也无论用什么编码传递,用什么编码获得,但是,只要他都能保持一种编码值,只要你在适当的时候(在其编码变为乱码之前)转换,仍旧是能够恢复到他的原始状态的! byte[] bytes = System.Text.Encoding.UTF8.GetBytes(sResultContents); ////取得的utf-8编码转换成gb2312编码///关键就这几句了 System.Text.Encoding utf8 = System.Text.Encoding.GetEncoding("utf-8"); System.Text.Encoding gb2312 = System.Text.Encoding.GetEncoding("gb2312"); System.Text.Encoding.Convert(utf8, gb2312, bytes); System.Text.Encoding.Convert(utf8, gb2312, bytes); 现在的问题是一个gb编码asp页面post带中文的数据到一个utf8编码的aspx页面数据显示是乱码例如<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title>无标题页</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /></head><body><form method="post" action="1.aspx"><input type="text" name="aa" /><input id="Submit1" type="submit" value="submit" /></form></body></html>public partial class _1 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { string ss = Request.Form["aa"]; ltl.Text = ss; }}结果显示是乱码 Request.ContentEncoding = Encoding.GetEncoding("gb2312"); request.getParameter("").getBytes("utf-8").toString();没有用,c#和vb都没有这个 datalist中的dropdownlist的取值 DataSet如何处理海量数据 asp.net 怪问题 新手 有点问题问问 iframe我设置了字体样式,可是输出时样式全没了,如字体的颜色,字号等? c#里怎么取得active directory里的帐户密码? ASP.NET: 如何弹出提示框? 根级别上的数据无效。 行 1,位置 1 这样的连接怎么会出现异常啊??? 请问在sql中怎样取时间? 150分 web.sitemap是什么?如何使用 客户端、服务器断传递数据的问题
然后各自使用各自的编码方案,这个不会有冲突的
http://www.***.com
http://bbs.***.com
把你们gb2312的文件全部转换成utf-8的
再改web.config
光改web.config是不行的要把gb2314转成urf8 不能批量转就用文件另存为urf8
而是原来页面提交一个有中文的数据到新页面
结果显示是乱码
现在我想要的是怎么转换这个数据才能正常显示
我试过这个不行
/// <summary>
/// 从一种编码到另一种编码
/// </summary>
/// <param name="str">源字符串</param>
/// <param name="From">From</param>
/// <param name="To">To</param>
/// <returns></returns>
string ConertStr(string str, string From, string To)
{ byte[] bs = System.Text.Encoding.GetEncoding(From).GetBytes(str);
bs = System.Text.Encoding.Convert(System.Text.Encoding.GetEncoding(From), System.Text.Encoding.GetEncoding(To), bs);
string res = System.Text.Encoding.GetEncoding(To).GetString(bs);
return res; }
中文乱码问题是普遍存在,但是都是可以解决的!而且有多种解决方法,楼主想要的获得后再转换就是可行的!在获得传递过来的数据后,加上.getBytes("utf-8").toString() 如:request.getParameter("").getBytes("utf-8").toString();确实是有用!至于你所谓的,在转换之前已经不是原始数据了!这我也不知道该怎么解释!
一个数据无论怎么传递,也无论用什么编码传递,用什么编码获得,但是,只要他都能保持一种编码值,只要你在适当的时候(在其编码变为乱码之前)转换,仍旧是能够恢复到他的原始状态的!
////取得的utf-8编码转换成gb2312编码///关键就这几句了
System.Text.Encoding utf8 = System.Text.Encoding.GetEncoding("utf-8");
System.Text.Encoding gb2312 = System.Text.Encoding.GetEncoding("gb2312");
System.Text.Encoding.Convert(utf8, gb2312, bytes);
System.Text.Encoding.Convert(utf8, gb2312, bytes);
post带中文的数据到一个utf8编码的aspx页面
数据显示是乱码例如
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题页</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<form method="post" action="1.aspx">
<input type="text" name="aa" /><input id="Submit1" type="submit" value="submit" />
</form>
</body>
</html>
public partial class _1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ss = Request.Form["aa"];
ltl.Text = ss;
}
}
结果显示是乱码
没有用,c#和vb都没有这个