| WebService-BuzzurlAPI documentation | Contained in the WebService-BuzzurlAPI distribution. |
WebService::BuzzurlAPI::Util - Buzzurl WebService API utility module
0.02
Buzzurl WebService API utility module
Drop utf8flag
Example:
my $str = WebService::BuzzurlAPI::Util::drop_utf8flag($utf8flagstr);
URLEncoding
Example:
my $str = WebService::BuzzurlAPI::Util::urlencode($str);
Akira Horimoto
Copyright (C) 2007 Akira Horimoto
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WebService-BuzzurlAPI documentation | Contained in the WebService-BuzzurlAPI distribution. |
package WebService::BuzzurlAPI::Util;
use strict; use base qw(Exporter); use Encode; our(@EXPORT_OK, $PKG_REGEXP, $VERSION); @EXPORT_OK = qw(drop_utf8flag urlencode); $PKG_REGEXP = qr/^WebService::BuzzurlAPI/; $VERSION = 0.02;
sub drop_utf8flag { my $str = (scalar @_ == 2 && (ref($_[0]) =~ $PKG_REGEXP || $_[0] =~ $PKG_REGEXP)) ? $_[1] : $_[0]; if($str ne "" && Encode::is_utf8($str)){ $str = Encode::encode_utf8($str); } return $str; }
sub urlencode { my $str = (scalar @_ == 2 && (ref($_[0]) =~ $PKG_REGEXP || $_[0] =~ $PKG_REGEXP)) ? $_[1] : $_[0]; if($str ne ""){ $str =~ s/([^\w ])/"%" . unpack("H2", $1)/eg; $str =~ tr/ /+/; } return $str; } 1; __END__