From e5d3de5c457d1a82c921b9bf2cd9a962970ce30e Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C4=B0smail=20D=C3=B6nmez?= Date: Tue, 4 Dec 2007 10:55:41 +0200 Subject: [PATCH] gitweb: use Perl built-in utf8 function for UTF-8 decoding. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: İsmail Dönmez Tested-by: Martin Koegler Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index ff5daa7901..24b31582af 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -695,10 +695,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); } -- 2.47.1