全角半角标点的转换:
sql code
--full2half
create function [dbo].[full2half](
@string nvarchar(max)
)
returns nvarchar(max)
as
/*
全角(fullwidth)转换为半角(halfwidth)
*/
begin
declare @chr nchar(1)
declare @i int
set @string = replace(@string,n' ',n' ')
set @i = patindex(n'%[!-~]%' collate latin1_general_bin,@string)
while @i > 0
begin
set @chr = substring(@string,@i,1)
set @string = replace(@string,@chr,nchar(unicode(@chr)-65248))
set @i = patindex(n'%[!-~]%' collate latin1_general_bin,@string)
end
return @string
end
go
create function [dbo].[half2full](
@string nvarchar(max)
)
returns nvarchar(max)
as
/*
半角(halfwidth)转换为全角(fullwidth)
*/
begin
declare @chr nchar(1)
declare @i int
set @string = replace(@string,n' ',n' ')
set @i = patindex(n'%[!-~]%' collate latin1_general_bin,@string)
while @i > 0
begin
set @chr = substring(@string,@i,1)
set @string = replace(@string,@chr,nchar(unicode(@chr)+65248))
set @i = patindex(n'%[!-~]%' collate latin1_general_bin,@string)
end
return @string
end
go
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com