(SQL Server) HTML Encoding
Demonstrates HTML encoding and decoding. Note: This example requires Chilkat v11.1.0 or greater.
-- Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
--
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @crypt int
EXEC @hr = sp_OACreate 'Chilkat.Crypt2', @crypt OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @s nvarchar(4000)
SELECT @s = '< é ü ç Ω Hello & World ✓ >'
DECLARE @htmlEncoded nvarchar(4000)
EXEC sp_OAMethod @crypt, 'EncodeString', @htmlEncoded OUT, @s, 'utf-8', 'html'
PRINT @htmlEncoded
-- Output:
-- < é ü ç Ω Hello & World ✓ >
-- To decode:
EXEC sp_OAMethod @crypt, 'DecodeString', @s OUT, @htmlEncoded, 'utf-8', 'html'
PRINT @s
-- Output:
-- < é ü ç Ω Hello & World ✓ >
EXEC @hr = sp_OADestroy @crypt
END
GO
|