
Jasmine
Administrator
Feb 5, 2000, 6:59 PM
Post #2 of 5
(5360 views)
|
Re: Need to Encode data for POST or GET
[In reply to]
|
Can't Post
|
|
Rita, if you require the CGI module in your program, there's 2 subroutines in it that'll help you url encode/decode (escape and unescape). If you'd rather not load CGI.pm into your program, then you could just use the following 2 subroutines, taken from CGI.pm: <BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR> # unescape URL-encoded data sub unescape { shift if ref($_[0]); my $todecode = shift; return undef unless defined($todecode); $todecode =~ tr/+/ /; # pluses become spaces $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge; return $todecode; } # URL-encode data sub escape { shift if ref($_[0]) | | $_[0] eq $DefaultClass; my $toencode = shift; return undef unless defined($toencode); $toencode=~s/([^a-zA-Z0-9_.-])/uc sprintf("%%%02x",ord($1))/eg; return $toencode; } </pre><HR></BLOCKQUOTE> 2) I'm confused. Are you referring to just passing data, or being able to, let's say, bookmark a page after data has been passed through POST. The latter won't work. The former can have data passed via html's <INPUT TYPE=HIDDEN VALUE="whatever"> tag. If I didn't answer your question, could you please elaborate a little? Good luck! [This message has been edited by Jasmine (edited 02-05-2000).]
|