From: İsmail Dönmez Date: Tue, 4 Dec 2007 08:55:41 +0000 (+0200) Subject: gitweb: use Perl built-in utf8 function for UTF-8 decoding. X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/aab9614336a9af3e4f453e35812b5d48269f2e7c39ba05d55f235bb05dc5d649 gitweb: use Perl built-in utf8 function for UTF-8 decoding. Signed-off-by: İsmail Dönmez Tested-by: Martin Koegler Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 68795d0..ec6d5f9 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -696,10 +696,9 @@ sub validate_refname { # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning sub to_utf8 { my $str = shift; - my $res; - eval { $res = decode_utf8($str, Encode::FB_CROAK); }; - if (defined $res) { - return $res; + if (utf8::valid($str)) { + utf8::decode($str); + return $str; } else { return decode($fallback_encoding, $str, Encode::FB_DEFAULT); }