Playwright Tests / test (push) Waiting to run
Add fis_wdg_* table functions for dashboard widgets and wire them into FuchsDatabase.sqlproj; update the invoice list procs accordingly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
1.1 KiB
Transact-SQL
26 lines
1.1 KiB
Transact-SQL
CREATE FUNCTION [dbo].[strings_encodeHTML](@inputText NVARCHAR(MAX))
|
|
RETURNS NVARCHAR(MAX)
|
|
AS
|
|
BEGIN
|
|
DECLARE @encodedText NVARCHAR(MAX) = N'';
|
|
|
|
IF DATALENGTH(@inputText) > 0
|
|
BEGIN
|
|
/* 1) Escape reserved HTML characters (& < >); FOR XML also entitizes CR as 
 */
|
|
SET @encodedText = CAST((SELECT @inputText AS [p] FOR XML PATH(''), TYPE) AS NVARCHAR(MAX));
|
|
|
|
/* 2) Remove the leading <p> and trailing </p> that FOR XML adds */
|
|
SET @encodedText = SUBSTRING(@encodedText, 4, LEN(@encodedText) - 7);
|
|
|
|
/* 3) Line breaks (CRLF, LF, lone CR) -> <br>; NBSP -> */
|
|
SET @encodedText = REPLACE(@encodedText, N'
' + NCHAR(10), N'<br>');
|
|
SET @encodedText = REPLACE(@encodedText, NCHAR(13) + NCHAR(10), N'<br>');
|
|
SET @encodedText = REPLACE(@encodedText, NCHAR(10), N'<br>');
|
|
SET @encodedText = REPLACE(@encodedText, N'
', N'<br>');
|
|
SET @encodedText = REPLACE(@encodedText, NCHAR(13), N'<br>');
|
|
SET @encodedText = REPLACE(@encodedText, NCHAR(160), N' ');
|
|
END
|
|
|
|
RETURN @encodedText;
|
|
END;
|