Re: Fix UTF Encoding issue

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

 



El 4/12/2007, a las 9:55, Ismail Dönmez escribió:

Tuesday 04 December 2007 10:47:39 Ismail Dönmez yazmıştı:
Tuesday 04 December 2007 10:44:12 Martin Koegler yazmıştı:
On Tue, Dec 04, 2007 at 10:33:39AM +0200, Ismail Dönmez wrote:
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 <ismail@xxxxxxxxxxxxx>

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;

This is good as it fixes another problem which some may have encountered. On at least one distro that I use (Red Hat Enterprise Linux 3) the Encode module is very old (it's 1.83; the latest release is 2.23), and so gitweb won't even run, dying during compilation with this:

Too many arguments for Encode::decode_utf8 at gitweb.cgi line 686, near "Encode::FB_CROAK)"

Of course, the workaround is to install a newer version of the module, but this patch eliminates that dependency which is IMO a good thing.

Cheers,
Wincent

-
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