不在web.config中设置requestEncoding="gb2312" ,服务器控件提交数据中文为乱码,怎么转化例如在textbox"输入中国留学生普遍存在英语语言基础薄弱" 乱码为"йѧձӢԻ"
1.<META http-equiv="content-type" content="text/html; charset=gb2312"> 试过不行
2.HttpUtility.UrlDecode(中文, System.Text.Encoding.GetEncoding("gb2312"))也不行
3.用了方法如下,还是不行
static public string EnCodeBase64(string code_type, string code)
{
string encode = "";
if (code_type == null)
{
code_type = "unicode";
}
if (code != null && code.Length > 0)
{
byte[] bytes = System.Text.Encoding.GetEncoding(code_type).GetBytes(code);
try
{
encode = Convert.ToBase64String(bytes);
}
catch
{
//encode = code;
}
}
return encode;
}
请教正确答案
1.<META http-equiv="content-type" content="text/html; charset=gb2312"> 试过不行
2.HttpUtility.UrlDecode(中文, System.Text.Encoding.GetEncoding("gb2312"))也不行
3.用了方法如下,还是不行
static public string EnCodeBase64(string code_type, string code)
{
string encode = "";
if (code_type == null)
{
code_type = "unicode";
}
if (code != null && code.Length > 0)
{
byte[] bytes = System.Text.Encoding.GetEncoding(code_type).GetBytes(code);
try
{
encode = Convert.ToBase64String(bytes);
}
catch
{
//encode = code;
}
}
return encode;
}
请教正确答案
解决方案 »
- C#导出数据到Excel过程中遇到的异常来自 HRESULT:0x800A03EC
- 听讲csdn上好多高手!对于我这个初哥问的问题应该好易给到答复??
- 望数据库高手帮助啊!关于子栏目查询的数据库设计
- DropDownList里怎么加上请选择
- config中的数据库连接问题?
- 一个判断语句
- 初学者求解使用gridview控件时where字句的问题
- TableAdapter配置中的SQL加了参数,怎么在WEB上复制给这些参数?
- 一个简单问题---------aspmenu如何用???
- 为何我的DataList中的EditItemTemplate老是修改不了啊?
- System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(TextBox1.Text, "MD5");的问题???急急
- .net 新手提问
改成这个试试
<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8"/>然后,把页面这句<META http-equiv="content-type" content="text/html; charset=gb2312"> 删除.最后,把这页xxx.aspx和xxx.aspx.cs均另存为UTF-8
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="imagetoolbar" content="no"/>
<meta content="MSHTML 6.00.2900.3157" name="GENERATOR"/>
<title>测试框架</title>
</head>换成我的这个试试