@matheusbsbs / matheus-bagliano / commits / 847abc0f2a
Fork 0

gitweb: refactor decode() for utf8 conversion

we already had a few place using decode() to convert perl internal encode to utf8. added a new thin wrapper to do just that. Signed-off-by: Yasushi SHOJI <yashi@atmark-techno.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Yasushi SHOJI committed Oct 2, 2006 at 06:21 UTC 847abc0f2a8d57bf4c1f13e948995491b6bc6f58
1 file changed +13 -7
gitweb/gitweb.perl
+13 -7
@@ -443,6 +443,12 @@ sub validate_refname {
443 return $input;
444 }
445
446 +# very thin wrapper for decode("utf8", $str, Encode::FB_DEFAULT);
447 +sub to_utf8 {
448 + my $str = shift;
449 + return decode("utf8", $str, Encode::FB_DEFAULT);
450 +}
451 +
452 # quote unsafe chars, but keep the slash, even when it's not
453 # correct, but quoted slashes look too horrible in bookmarks
454 sub esc_param {
@@ -465,7 +471,7 @@ sub esc_url {
471 # replace invalid utf8 character with SUBSTITUTION sequence
472 sub esc_html {
473 my $str = shift;
468 - $str = decode("utf8", $str, Encode::FB_DEFAULT);
474 + $str = to_utf8($str);
475 $str = escapeHTML($str);
476 $str =~ s/\014/^L/g; # escape FORM FEED (FF) character (e.g. in COPYING file)
477 $str =~ s/\033/^[/g; # "escape" ESCAPE (\e) character (e.g. commit 20a3847d8a5032ce41f90dcc68abfb36e6fee9b1)
@@ -668,7 +674,7 @@ sub format_subject_html {
674
675 if (length($short) < length($long)) {
676 return $cgi->a({-href => $href, -class => "list subject",
671 - -title => decode("utf8", $long, Encode::FB_DEFAULT)},
677 + -title => to_utf8($long)},
678 esc_html($short) . $extra);
679 } else {
680 return $cgi->a({-href => $href, -class => "list subject"},
@@ -845,7 +851,7 @@ sub git_get_projects_list {
851 -e "$projectroot/$path/$export_ok")) {
852 my $pr = {
853 path => $path,
848 - owner => decode("utf8", $owner, Encode::FB_DEFAULT),
854 + owner => to_utf8($owner),
855 };
856 push @list, $pr
857 }
@@ -874,7 +880,7 @@ sub git_get_project_owner {
880 $pr = unescape($pr);
881 $ow = unescape($ow);
882 if ($pr eq $project) {
877 - $owner = decode("utf8", $ow, Encode::FB_DEFAULT);
883 + $owner = to_utf8($ow);
884 last;
885 }
886 }
@@ -1236,7 +1242,7 @@ sub get_file_owner {
1242 }
1243 my $owner = $gcos;
1244 $owner =~ s/[,;].*$//;
1239 - return decode("utf8", $owner, Encode::FB_DEFAULT);
1245 + return to_utf8($owner);
1246 }
1247
1248 ## ......................................................................
@@ -3589,7 +3595,7 @@ XML
3595 "<![CDATA[\n";
3596 my $comment = $co{'comment'};
3597 foreach my $line (@$comment) {
3592 - $line = decode("utf8", $line, Encode::FB_DEFAULT);
3598 + $line = to_utf8($line);
3599 print "$line<br/>\n";
3600 }
3601 print "<br/>\n";
@@ -3598,7 +3604,7 @@ XML
3604 next;
3605 }
3606 my $file = esc_html(unquote($7));
3601 - $file = decode("utf8", $file, Encode::FB_DEFAULT);
3607 + $file = to_utf8($file);
3608 print "$file<br/>\n";
3609 }
3610 print "]]>\n" .