NAME
CGI::Uricode - uri-en/decode a data for CGI program.
SYNOPSIS
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'};
DESCRIPTION
This module provides a set of functions for the data about application/x-www-form-urlencoded
.
FUNCTIONS
- uri_encode( $name1 => $value1 [, $name2 => $value2, ...] )
-
Exportable function. With the given $name and $value pairs, this function encode, construct and return a string of paired
$name=$value
strings those which are joined with `&' characters.$encoded = uri_encode(%param);
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 order of which they have been given. So you can control the order of the$name=$value
strings in the output string.The
application/x-www-form-urlencoded
is specified in the HTML 4.01 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)
-
Exportable function. This function decord and return the name and the value pairs from the given uri-encoded string. You might input them into a hash (%).
%param = uri_decode($encoded);
- uri_escape($string)
-
Exportable function. This function escape the given string. The return value of the function is the number of escaped characters. The uri-escape is specified in the RFC 2396 http://www.ietf.org/rfc/rfc2396.txt (and it is partially updated by the RFC 2732). The module URI::Escape does the similar function.
- uri_unescape($string)
-
Exportable function. This function unescape the given uri-escaped string. The return value of the function is the number of unescaped characters.
SEE ALSO
- HTML 4.01: http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1
- RFC 2396: http://www.ietf.org/rfc/rfc2396.txt (URI)
- RFC 2732: http://www.ietf.org/rfc/rfc2732.txt (URI)
AUTHOR
Masanori HATA http://go.to/hata (Saitama, JAPAN)
COPYRIGHT
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.