|
CGI::Uricode - uri-en/decode a data for CGI program. |
CGI::Uricode - uri-en/decode a data for CGI program.
use CGI::Uricode qw(uri_encode uri_decode);
my %input = (
'name' => 'Masanori HATA',
'mail' => 'lovewing@dream.big.or.jp',
'home' => 'http://go.to/hata',
);
my $encoded = uri_encode(%input);
print $encoded;
my %output = uri_decode($encoded);
print 'name: ', $output{'name'}; # displays "name: Masanori HATA"
This module provides a set of functions for the data about application/x-www-form-urlencoded.
uri_encode(%param)$name=$value strings those which are joined with ``&'' characters.
Though it is expressed virtually input into a hash (%), it is actually input into an arry (@). The Joined $name=$value strings in the output string will appear in the exact sequence of which they have been given. So you can control the order of the $name=$value strings in the output string. If you just give a real hash (%) to the function, the order of the $name=$value strings those which will appear in the output string will be random.
$encoded = uri_encode(
name1 => value1,
name2 => value2,
(...)
);
$encoded = "name1=value1&name2=value2&(...)";
The application/x-www-form-urlencoded is specified in the HTML 4 http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1.
With this function, by internally using the uri_escape() function, [SPACE] characters will be converted to ``%20'' strings to escape. This is normal manner in the HTTP ``POST'' method. To convert [SPACE] characters to ``+'' characters might occur in HTTP ``GET'' method to indicate the delimiters of query words, however this fuction won't do.
uri_decode($string)%param = uri_decode($encoded);
uri_escape($string)uri_unescape($string)
Masanori HATA http://go.to/hata (Saitama, JAPAN)
Copyright (c) 1999-2005 Masanori HATA. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
|
CGI::Uricode - uri-en/decode a data for CGI program. |