gitweb: use Perl built-in utf8 function for UTF-8 decoding.
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>
İsmail Dönmez committed
Dec 4, 2007 at 10:55 UTC
e5d3de5c457d1a82c921b9bf2cd9a962970ce30e
1 file changed
+3
-4
gitweb/gitweb.perl
+3
-4
@@ -695,10 +695,9 @@ sub validate_refname {
695
# in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
696
sub to_utf8 {
697
my $str = shift;
698
- my $res;
699
- eval { $res = decode_utf8($str, Encode::FB_CROAK); };
700
- if (defined $res) {
701
- return $res;
698
+ if (utf8::valid($str)) {
699
+ utf8::decode($str);
700
+ return $str;
701
} else {
702
return decode($fallback_encoding, $str, Encode::FB_DEFAULT);
703
}