[PATCH] Use perl builtin class utf8 for UTF-8 decoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio it would be very nice to get this in 1.5.4, fixes multiple problems and 
tested with many distros with success.

Use perl builtin class utf8 for UTF-8 decoding, this fixes Encode problems 
with older Encode and avoids problems on UTF-8 locales.

Signed-off-by: İsmail Dönmez <ismail@xxxxxxxxxxxxx>
Acked-by: Jakub Narebski <jnareb@xxxxxxxxx>
Tested-by: Martin Koegler <mkoegler@xxxxxxxxxxxxxxxxx>
Tested-by: Wincent Colaiuta <win@xxxxxxxxxxx>

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ff5daa7..db255c1 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);
 	}


-- 
Never learn by your mistakes, if you do you may never dare to try again.
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux