HTML_ENCODE function [Miscellaneous]

Encodes special characters within strings to be inserted into HTML documents.

Syntax

HTML_ENCODE( string )

Parameters

Returns

LONG VARCHAR or LONG NVARCHAR.

Note: The result data type is a LONG VARCHAR. If you use HTML_ENCODE in a SELECT INTO statement, you must have an Unstructured Data Analytics Option license or use CAST and set HTML_DECODE to the correct data type and size.

Remarks

This function returns the string argument after making the following set of substitutions:

Characters Substitution
" "
' '
& &
< &lt;
> &gt;
codes nn less than 0x20 &#xnn;

This function supports NCHAR inputs and/or outputs.

Standards and compatibility

Examples

The following example returns the string '&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot;&gt; '.

SELECT HTML_ENCODE('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">')