cvs commit: perlfaq perlfaq9.pod
[email protected] (brian d foy) 21 Nov 2005 17:43:13 -0000
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 05/11/21 09:43:13
Modified: . perlfaq9.pod
Log:
* added an [[:xdigit]] example to %-decoding
Revision Changes Path
1.26 +3 -4 perlfaq/perlfaq9.pod
Index: perlfaq9.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq9.pod,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- perlfaq9.pod 10 Nov 2005 00:35:31 -0000 1.25
+++ perlfaq9.pod 21 Nov 2005 17:43:13 -0000 1.26
@@ -253,19 +253,18 @@
=head2 How do I decode or create those %-encodings on the web?
-
If you are writing a CGI script, you should be using the CGI.pm module
that comes with perl, or some other equivalent module. The CGI module
automatically decodes queries for you, and provides an escape()
function to handle encoding.
-
The best source of detailed information on URI encoding is RFC 2396.
Basically, the following substitutions do it:
s/([^\w()'*~!.-])/sprintf '%%%02x', ord $1/eg; # encode
- s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
+ s/%([A-Fa-f\d]{2})/chr hex $1/eg; # decode
+ s/%([[:xdigit:]]{2})/chr hex $1/eg; # same thing
However, you should only apply them to individual URI components, not
the entire URI, otherwise you'll lose information and generally mess