天天看點

Asp.net中的頁面亂碼的問題

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.???沖??芥??瀛???锛?涓?瀹?瑕???NICODE?ゆ??锛?

--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涓?臧???23'' select dbo.hw(@a) --return: 1 set @a=N''abc涓???23'' 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 ????浠堕??浠舵????娌℃???????ㄦ?f??涓???涔辯??

http://community.csdn.net/Expert/topic/3172/3172047.xml?temp=.3463404

6.??涔?瑙e?蟲?ヨ?㈠??绗?覆涓???涔辯????棰?锛?

?ヨ?㈠??瀹圭??erver.UrlEncode缂???

string url ="http://localhost/test/test.aspx?a="+ Server.UrlEncode("寮?涓?");

瑙?

-->Server.UrlDecode()?

?