HTMLENCODE Function


HTMLENCODE Function

Encodes characters using HTML character entity references and returns the encoded string

Category: Web Tools

Syntax

HTMLENCODE ( expression , <options> )

Arguments

expression

  • specifies any character expression. By default, any greater-than (>), less-than (<), and ampersand (&) characters are encoded as & gt; , & lt; , and & amp; , respectively. In SAS 9 only, this behavior can be modified with the options argument.

    Note: The encoded string can be longer than the original string. You should take the additional length into consideration when you define your output variable. If the encoded string exceeds the maximum length that is defined, the output string might be truncated.

    options

  • specifies the type of characters to encode. The value can be any string expression. If you use more than one option, separate the options by spaces. See 'Details' on page 582 for a list of valid options.

    Note: This argument is available in SAS 9 only.

Details

Option

Character

Character Entity Reference

Description

amp

gt

lt

&

>

<

&amp;

&gt;

&lt;

The HTMLENCODE function encodes these characters by default. If you need to encode these characters only, then you do not need to specify the options argument. However, if you specify any value for the options argument, then the defaults are overridden, and you must explicitly specify the options for all of the characters you want to encode.

apos

'

&apos;

Use this option to encode the apostrophe ( ') character in text that is used in an HTML or XML tag attribute.

quot

"

&quot;

Use this option to encode the double quotation mark (") character in text that is used in an HTML or XML tag attribute.

7bit

any character that is not represented in 7-bit ASCII encoding

&#x nnn ; (Unicode)

nnn is a one or more digit hexadecimal number. Encode these characters to create HTML or XML that is easily transferred through communication paths that might only support 7-bit ASCII encodings (for example, ftp or e-mail).

Examples

SAS Statements

Results

htmlencode("John's test < tag > ")

John's test & lt;tag & gt;

htmlencode("John's test < tag > ",'apos')

John & apos;s test < tag >

htmlencode('John "Jon" Smith < tag > ','quot')

John & quot;Jon & quot; Smith < tag >

htmlencode("'A & B & C ' ",'amp lt gt apos')

& apos;A & amp;B & amp;C & apos;

htmlencode('80'x, '7bit')

& #x20AC;

('80'x is the euro symbol in Western European locales.)

(20AC is the Unicode code point for the euro symbol.)

See Also

Function:

  • 'HTMLDECODE Function' on page 580




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net