Encoded_Text as C = *HTML_ESCAPE(C text[,C flags])



Text encoded for HTML use.


Text as Displayed on a monitor.


Optional. Default = "". HTML encoding rules. Character

"" = Escape all characters with values above 127 and some of the other low punctuation characters (i.e. like dash & back-quote).
"B" = encode space characters as non-breaking spaces ()
"S" = short list of characters to encode. Only escape & , ' , " , < ,>characters.
"SC" = encode with hexadecimal values (used on command lines)
"Q" = an alternative to the "S" option to omit encoding the single quote character.
"E" = Do not encode encoded unicode characters (e.g. &#x0* pattern). If you use the 'E' flag, the '&' in the text that matches the encoded unicode character pattern is not encoded.
"UTF8" = Encode special characters as well as UTF8 encoded high order characetrs.
"UTF8H" = Encode only UTF8 encoded high order characetrs.


The *HTML_ESCAPE() function encodes text for HTML use. Escape HTML characters, flags - 'B'lanks translated, 'S'hort list (&,",',<,>), 'Q'uotes excluded short (&,",<,>), 'D'ouble quotes only("), 'L' - label format.


This conversion uses no flags.

? *html_escape("This is <...> text")
= "This is < > text"

This conversion encodes space characters as non-breaking spaces.

? *html_escape("This is <...> text","b")
= "This is < > text"

This conversion defines a short list of characters to encode

? *html_escape("This is <...> text","s")
= "This is <...> text"

SC - encode with hexadecimal values

? *html_escape("This is <...> text","sc")
= "This#20is#20<#FA>#20text"

UTF8 - Treat high order characters as UTF8 encoding, and escape them.

' chinese characters for china (Middle + Kingdom)
dim china as c = *unicode_to_utf8(20013)+*unicode_to_utf8(22269)
= "&#x4e2d;&#x56fd;"

UTF8H - If you wanted to keep the special HTML characters, but convert any high order characters from utf8 encoded characters to escaped HTML characters. This is useful for processing templates with high order characters so that code page for the html is not an issue.

' chinese characters for china (Middle + Kingdom)
dim china as c = "<b>"+*unicode_to_utf8(20013)+*unicode_to_utf8(22269)+"</b>"
= "&lt;b&gt;&#x4e2d;&#x56fd;&lt;/b&gt;"
= "<b>&#x4e2d;&#x56fd;</b>"

See Also