I've fixed the problem for my installation usign a wrapper script, as
I'm not sending a patch because I'm no expert in Perl and I'm unsure that
the solution I've found is the right one, but in the hope that my description
of the problem and the provided solution will be useful for others.
When using gitweb.cgi in FCGI mode the answers from the script are returned
using the wrong encoding (UTF-8 characters are printed as LATIN-1).
It seems that the problem appears because the FCGI streams are implemented
using the older stream API, TIEHANDLE and applying PerlIO layers using
binmode() has no effect to them.
A solution similar to the use of binmode for the output stream is to
redefine the FCGI::Stream::PRINT function to use UTF-8 as output encoding.
To do it with minimal chages I've created a gitweb.cgi wrapper that
redefines the function and runs the original script; I'm doing it like this
to be able to use the packaged script until upstream includes a fix for the
Wrapper code (uses /usr/share/gitweb/gitweb.cgi as the PATH for gitweb.cgi):
# gitweb.cgi wrapper that fixes the UTF-8 problem with fastcgi
# Local redefinition of FCGI::Stream::PRINT