Subject: | please use utf8::encode rather than Encode::encode_utf8 |
This is not a bug but I'd like to report this anyway.
uri_escape_utf8 function was added recently added to URI::Escape,
and it uses Encode::encode_utf8 function from Encode module.
If you look at encode_utf8 function from Encode module,
it appears to be very simple:
sub encode_utf8($)
{
my ($str) = @_;
utf8::encode($str);
return $str;
}
So there seems to be no need to load Encode because of this simple function.
The attached patch makes uri_escape_utf8 function use utf8::encode function directly.
I hope this makes sense,
and thanks,
Alexey Tourbin
ALT Linux Team
--- URI-1.32/URI/Escape.pm- 2004-04-13 15:17:27 +0000
+++ URI-1.32/URI/Escape.pm 2004-09-08 16:05:14 +0000
@@ -179,14 +179,13 @@ sub _fail_hi {
sub uri_escape_utf8
{
+ my $text = shift;
if ($] < 5.008) {
- my $text = shift;
$text =~ s/([^\0-\x7F])/do {my $o = ord($1); sprintf("%c%c", 0xc0 | ($o >> 6), 0x80 | ($o & 0x3f)) }/ge;
- return uri_escape($text, @_);
+ } else {
+ utf8::encode($text);
}
-
- require Encode;
- return uri_escape(Encode::encode_utf8(shift), @_);
+ return uri_escape($text, @_);
}
sub uri_unescape