CGI-Utils
view release on metacpan or search on metacpan
68697071727374757677787980818283848586878889909192
Aliases: url_encode()
urlUnicodeEncode(
$str
)
Returns the fully URL-encoded version of the
given
string as unicode
characters. It does not convert space characters to
'+'
characters.
Aliases: url_unicode_encode()
urlDecode(
$url_encoded_str
)
Returns the decoded version of the
given
URL-encoded string.
Aliases: url_decode()
urlUnicodeDecode(
$url_encoded_str
)
Returns the decoded version of the
given
URL-encoded string,
with
unicode support.
Aliases: url_unicode_decode()
urlEncodeVars(
$var_hash
,
$sep
)
Takes a hash of name/value pairs and returns a fully URL-encoded query
string suitable
for
passing in a URL. By
default
, uses the newer
separator, a semicolon, as recommended by the W3C. If you pass in a
second argument, it is used as the separator between key/value pairs.
lib/CGI/Utils.pm view on Meta::CPAN
328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
my
(
$self
,
$str
) =
@_
;
$str
=~ s{([^A-Za-z0-9_])}{
sprintf
(
"%%u%04x"
,
ord
($1))}eg;
return
$str
;
}
*url_unicode_encode
= \
&urlUnicodeEncode
;
=pod
=head2 urlDecode($url_encoded_str)
Returns the decoded version of the given URL-encoded string.
Aliases: url_decode()
=cut
sub
urlDecode {
my
(
$self
,
$str
) =
@_
;
$str
=~
tr
/+/ /;
$str
=~ s|%([A-Fa-f0-9]{2})|
chr
(
hex
($1))|eg;
return
$str
;
}
*url_decode
= \
&urlDecode
;
=pod
=head2 urlUnicodeDecode($url_encoded_str)
Returns the decoded version of the given URL-encoded string,
with unicode support.
Aliases: url_unicode_decode()
=cut
sub
urlUnicodeDecode {
my
(
$self
,
$str
) =
@_
;
$str
=~
tr
/+/ /;
$str
=~ s|%([A-Fa-f0-9]{2})|
chr
(
hex
($1))|eg;
$str
=~ s|
%u
([A-Fa-f0-9]{2,4})|
chr
(
hex
($1))|eg;
( run in 0.238 second using v1.01-cache-2.11-cpan-1dc43b0fbd2 )