Functions and CALL Routines |
Encodes characters using HTML character entity references, and
returns the encoded string.
HTMLENCODE(expression,
<options>)
|
-
expression
-
specifies a character constant, variable,
or expression. By default, any greater-than (>), less-than (<), and ampersand
(&) characters are encoded as >
, <
,
and &
, respectively.
In SAS 9 only, this behavior can be modified with the options
argument.
Note: The encoded string can be longer than
the output 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
-
is a character constant, variable, or expression
that specifies the type of characters to encode. If you use more than one
option, separate the options by spaces. The following options are available:
Option |
Character |
Character Entity Reference |
Description |
amp |
& |
& |
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. |
gt |
> |
> |
lt |
< |
< |
apos |
' |
' |
Use this option to encode the apostrophe (
' ) character in text that is used in an HTML or XML tag
attribute. |
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 |
&#xnnn; (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 support only 7-bit ASCII encodings
(for example, ftp or e-mail). |
SAS Statements |
Results |
htmlencode("John's test <tag>")
|
John's test <tag>
|
htmlencode("John's test <tag>",'apos')
|
John's test <tag>
|
htmlencode('John "Jon" Smith <tag>','quot')
|
John "Jon" Smith <tag>
|
htmlencode("'A&B&C'",'amp lt gt apos')
|
'A&B&C'
|
htmlencode('80'x, '7bit')
('80'x
is the euro symbol in Western European locales.) |
€
(20AC is the
Unicode code point for the euro symbol.) |
Copyright © 2011 by SAS Institute Inc., Cary, NC, USA. All rights reserved.