koha-devel
[Top][All Lists]
Advanced

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

[Koha-devel] Re: iso-8859-2 - probelm


From: address@hidden via news-to-mail gateway
Subject: [Koha-devel] Re: iso-8859-2 - probelm
Date: Sun Jan 12 20:19:03 2003

Hi,

In article <address@hidden>,
Benedict <address@hidden> 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  <address@hidden>
http://ada.dhs.org/~acli/cmcc/  http://www.cccgt.org/

DRM is theft - We are the stakeholders



reply via email to

[Prev in Thread] Current Thread [Next in Thread]