Date: Mon, 30 Nov 1998 21:51:24 +1100
Reply-To: Paul Homes <pahomes@SPS-OZ.COM.AU>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Paul Homes <pahomes@SPS-OZ.COM.AU>
Subject: Tip: New Web functions in SAS/IntrNet 1.2
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
For those of you out there who are web developers there are a couple of new functions that slipped into SAS/IntrNet 1.2 recently - urlencode() and urldecode(). I find urlencode() the more useful of the two - it is used to encode text containing spaces and punctuation for inclusion in a URL. For example the following code encodes the variable named text before using it in a hyperlink:
data _null_;
text="This string contains characters !@#$%^& that must be encoded";
html=
'<a href="/cgi-bin/broker.exe?_service=default&_program=test.echo.sas&text='
!!urlencode(text)
!!'">Show encoded text</a>'
;
put html;
run;
which produces the following valid HTML hyperlink:
<a href="/cgi-bin/broker.exe?_service=default&_program=test.echo.sas&text=This%20string%20contains%20characters%20%21@%23%24%25%5E%26%20that%20must%20be%20encoded">Show encoded text</a>
Urldecode() works the other way to decode these cryptic strings e.g.
data _null_;
text="%21Hello+World%21";
text=urldecode(text);
put text=;
run;
which produces:
TEXT=!Hello World!
As far as status goes - I have been told that although they are non-production in 6.12, they are simple enough to be considered quite reliable from the exposure they have had so far. They are production in V7 and are accompanied by another 2 new functions - htmlencode() and htmldecode().
Does anyone have any ideas, that we could feedback, for more web related functions that would make our lives easier?
Cheers
Paul
-------------------------------------------------------------
Paul Homes, Technical Manager, SPS (Australia)
phone: +61 (412) 007 088 fax: +61 (2) 9566 1849
email: pahomes@sps-oz.com.au web: http://www.sps-oz.com.au/