时间:2020-10-20 13:12:17 | 栏目:.NET代码 | 点击:次
1.<globalization
requestEncoding="gb2312"
responseEncoding="gb2312"
/>
或者
<META http-equiv="content-type" content="text/html; charset=gb2312">
Response.AddHeader("Content-Disposition", "attachment; filename="+HttpUtility.UrlEncoding(filename.ToString ()));
/*******该函数返回字符串中除英文外的字符*********/
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 行)
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
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"));