Hi, In article <E18XXdh-0003An-00@sc8-sf-list1.sourceforge.net>, Benedict <kb2qzv@poczta.wp.pl> wrote:
I don't know whether this is a Konqueror problem or a Koha flaw...but each time I access this page http://localhost:8080/cgi-bin/koha/members-home.pl Konqueror reverses to iso-8859-1 and polish characters get scrambled. I tried to insert <meta http-equiv=...> tag but to no avail.
I have found the culprit of the problem; it is neither Konquerer nor Koha. It is CGI.pm. It seems that CGI.pm has the bad habit of assuming that everything is in ISO-8859-1 unless we explictly override it. (Passing it -type => 'text/html' is not enough; it will still output 'Content-Type: text/html; charset=ISO-8859-1'.) The following patch demonstrates the problem: -------------- cut here ------------ 8< ------------------------- --- mainpage.pl.dist Sun Jan 12 22:51:22 2003 +++ mainpage.pl Sun Jan 12 23:16:28 2003 @@ -17,4 +17,15 @@ debug => 1, }); -print $query->header(-cookie => $cookie), $template->output; +# CGI.pm assumes that everything is in ISO-8859-1 unless overridden +# This breaks non-Latin1 languages such as Polish and Chinese +# We *must* guess the correct charset and explictly override it + +my $output = $template->output; +my $charset = $1 if /<meta\s+http-equiv=(["']?)Content-Type\1\s+content=(["'])text\/html;\s*charset=[^\2]\2>/is; +my $type = defined $charset? 'text/html': "text/html; charset=$1"; + +print $query->header( + -type => $type, + -cookie => $cookie, +), $output; -------------- cut here ------------ 8< ------------------------- After applying this patch, the login screen is still forced into ISO-8859-1, but after logging in, the main screen will be correctly displayed in ISO-8859-2. Of course, this only fixes one page :-( I suppose the "easiest" option for us is to create a new function somewhere in C4 to do the above, and no other Koha code should call CGI.pm's "header" method. We will need to find out where the "header" method is being called, and change every function call to use the new function that will be written. -- Ambrose Li <a.c.li@ieee.org> http://ada.dhs.org/~acli/cmcc/ http://www.cccgt.org/ DRM is theft - We are the stakeholders