Created
August 16, 2011 07:01
-
-
Save azcoov/1148579 to your computer and use it in GitHub Desktop.
SQL HTML Encoding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function dbo.fn_HtmlEncode ( | |
@Html as varchar ( max ) | |
) | |
returns varchar ( max ) | |
as | |
/* | |
select dbo.fn_HtmlEncode('<This is a T&st #>') | |
*/ | |
begin | |
declare @encoded as varchar ( max ) | |
select @encoded = | |
replace ( | |
replace ( | |
replace ( | |
replace ( | |
replace ( @Html, '&' , '&' ), | |
'<' , '<' ), | |
'>' , '>' ), | |
' ' , '+' ), | |
'#' , '%23' ) | |
return @encoded | |
end | |
go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment