当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > Asp.net中的页面乱码的问题

ASP.NET
安装IE补丁后ASP.NET将无法运行
在ASP.Net中应用Javascript
用ASP.NET 1.1 新特征防止Script攻击
ASP.NET中在线用户统计的简单实现及讨论
ASP.NET中将数据输出到Excel
在ASP.NET中从SQL Server检索图片
ASP.NET系统用户权限设计与实现
利用ASP.NET技术动态生成HTML页面
大数量查询分页显示 微软的解决办法
ASP.NET WEB页面多语言支持解决方案
ASP.NET 2.0里轻松获取数据库连接统计数据
ASP.NET通过DSO访问分析服务器的权限问题
ASP实现禁止从外部提交数据
Asp.Net 使用 GDI+ 绘制3D饼图入门篇源码
在ASP.NET中点击一个按钮后让它变灰的简单方法
利用JS在asp.net中实现左导航页的隐藏
asp.net中一次更新DATAGRID中所有记录
用Asp.net屏蔽F5、Ctrl+N、Alt+F4
asp.net中用C#实现站点计数器用户控件
认识ASP.NET配置文件Web.config

ASP.NET 中的 Asp.net中的页面乱码的问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 88 ::
收藏到网摘: n/a

1.<globalization
 requestEncoding="gb2312"
 responseEncoding="gb2312"
 />
 
或者
 
<META http-equiv="content-type" content="text/html; charset=gb2312">
 
 
2.下载文件时指定文件名,中文的文件名出现了乱码?
 
Response.AddHeader("Content-Disposition", "attachment; filename="+HttpUtility.UrlEncoding(filename.ToString ()));
 
 
 
 
3.如何识别字符串中是否包含韩文
 
http://search.csdn.net/Expert/topic/2456/2456407.xml?temp=.5485498
 
如果只有英文和韩文
/*******该函数返回字符串中除英文外的字符*********/
create function test(@a varchar(20))
returns varchar(20)
as
begin
 declare @b varchar(20),@i int
 set @b = ''
 set @i = 1
 while @i<= len(@a)
 begin
 if Upper(substring(@a,@i,1)) not between 'A' and 'Z'
 set @b = @b + substring(@a,@i,1)
 set @i = @i+1
 end
 return @b
end
 
Select dbo.test('aabc12dsa451')
 
 
--------------------
12451
 
(所影响的行数为 1 行)
--1.有关多国文字的,一定要用UNICODE判断!
--2.韩文UNICODE分两断: 12592->12687  44032->55203
相关网站:http://www.buja.8u8.com/eeeeee.htm
 
 
create function hw(@str Nvarchar(100))
returns int
as
begin
declare @a int
set @a=0
while @str<>'' and @a=0
 begin
 set @a=(case when unicode(left(@str,1)) between 12592 and 12687
 or unicode(left(@str,1)) between 44032 and 55203
 then 1
 else 0 end)
 set @str=right(@str,len(@str)-1)
 end
return @a
end
 
--调用:
declare @a nvarchar(100)
set @a=N'abc中갃国123'
select dbo.hw(@a)
 
--return: 1
 
 
set @a=N'abc中国123'
select dbo.hw(@a)
 
--return: 0
 
 
 
 
4.为什么文件读出来的中文字符是乱码?
 
System.IO.StreamReader m_fs = System.IO.File.OpenText(Hfile_SelectFile.Value);
改为
System.IO.StreamReader m_fs = new System.IO.StreamReader(Hfile_SelectFile.Value,System.Text.Encoding.GetEncoding("gb2312"));
 
 
5.JMAIL 发邮件附件或者没有或者在正文中是乱码
 
http://community.csdn.net/Expert/topic/3172/3172047.xml?temp=.3463404
 
6.怎么解决查询字符串中文乱码问题?
 
查询内容用Server.UrlEncode编码
 
string url ="http://localhost/test/test.aspx?a="+ Server.UrlEncode("张三");

-->Server.UrlDecode()