Thread (23 messages) flat view 23 messages, 6 authors, 2016-06-15

Re: Fix UTF Encoding issue

From: Ismail Dönmez <hidden>
Date: 2016-06-15 22:43:56
Subsystem: the rest · Maintainer: Linus Torvalds

Possibly related (same subject, not in this thread)

Tuesday 04 December 2007 10:47:39 Ismail Dönmez yazmıştı:
Tuesday 04 December 2007 10:44:12 Martin Koegler yazmıştı:
quoted
On Tue, Dec 04, 2007 at 10:33:39AM +0200, Ismail Dönmez wrote:
quoted
Following to_utf8 function works for me :
For me too (Debian sarge+etch).
Thanks for testing.
Use Perl built-in utf8 function for UTF-8 decoding.

Signed-off-by: İsmail Dönmez <redacted>
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help