gitweb: use Perl built-in utf8 function for UTF-8 decoding.
authorİsmail Dönmez <ismail@pardus.org.tr>
Tue, 4 Dec 2007 08:55:41 +0000 (10:55 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 4 Dec 2007 22:43:21 +0000 (14:43 -0800)
Signed-off-by: İsmail Dönmez <ismail@pardus.org.tr>
Tested-by: Martin Koegler <mkoegler@auto.tuwien.ac.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
gitweb/gitweb.perl

index ff5daa7901d9976dc35e1b4a05e1cf0140297d6a..24b31582afbc78415a5ce34acf06e0d589be0f91 100755 (executable)
@@ -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);
        }