make necessary changes to output UTF8 files and pages instead of ISO8859-1 and make...
authormh <mh>
Tue, 30 Apr 2002 17:42:18 +0000 (17:42 +0000)
committermh <mh>
Tue, 30 Apr 2002 17:42:18 +0000 (17:42 +0000)
13 files changed:
source/Mir.java
source/OpenMir.java
source/config.properties-dist
source/mir/misc/HTMLTemplateProcessor.java
source/mir/storage/Database.java
source/mircoders/producer/Producer.java
templates-dist/admin/start_admin.template
templates-dist/producer/content.template
templates-dist/producer/featuresRSS.template
templates-dist/producer/openposting.template
templates-dist/producer/startpage.template
templates-dist/producer/topiclist.template
templates-dist/producer/wml2.xsl

index de34636..f6c70f4 100755 (executable)
@@ -62,7 +62,8 @@ public class Mir extends AbstractServlet {
         session = req.getSession(true);
 
         if (req.getServerPort() == 443) http = "https"; else http = "http";
-        res.setContentType("text/html");
+        res.setContentType("text/html; charset="
+                            +MirConfig.getProp("Mir.DefaultEncoding"));
         String moduleName = req.getParameter("module");
 
         checkLanguage(session, req);
@@ -302,7 +303,7 @@ public class Mir extends AbstractServlet {
     }
 
     public String getServletInfo() {
-        return "Mir 1.0 rev02 multilanguage";
+        return "Mir "+MirConfig.getProp("Mir.Version");
     }
 
     private void checkLanguage(HttpSession session, HttpServletRequest req) {
index b855083..8a8bb9a 100755 (executable)
@@ -52,7 +52,8 @@ public class OpenMir extends AbstractServlet {
       setLanguage(session,getAcceptLanguage(req));
     }
 
-    res.setContentType("text/html");
+    res.setContentType("text/html; charset="
+                      +MirConfig.getProp("Mir.DefaultEncoding"));
     try {
       ServletModuleDispatch.dispatch(ServletModuleOpenIndy.getInstance(),req,res);
     }
@@ -103,7 +104,9 @@ public class OpenMir extends AbstractServlet {
 
   }
 
-  public String getServletInfo(){ return "OpenIndy 1.0 rev01"; }
+  public String getServletInfo(){
+    return "OpenMir "+MirConfig.getProp("Mir.Version");
+  }
 
 }
 
index 66534e4..ed949a9 100755 (executable)
@@ -198,6 +198,11 @@ Entity.Logfile=log/dbentity.log
 # Servlet / Module configurations
 #
 
+# don't change this unless you really know your i18n.
+# The default encoding charset used in the written html files as well
+# as the dynamic output html.
+# also used for the HTML charset meta tag.
+Mir.DefaultEncoding=UTF8
 Mir.Logfile=log/mir.log
 Mir.ErrorTemplate=error.template
 Mir.UserErrorTemplate=usererror.template
index c2f10f2..062fd39 100755 (executable)
@@ -32,6 +32,7 @@ public final class HTMLTemplateProcessor {
   private static String               imageHost;
   private static String               imagePath;
   private static String               openAction;
+  private static String               defEncoding;
   protected static String producerDocRoot =
                MirConfig.getProp("Producer.DocRoot");
   protected static String producerStorageRoot =
@@ -60,6 +61,7 @@ public final class HTMLTemplateProcessor {
 
     actionRoot = docRoot + "/servlet/Mir";
 
+    defEncoding = MirConfig.getProp("Mir.DefaultEncoding");
     openAction = MirConfig.getProp("Producer.OpenAction");
     productionHost = MirConfig.getProp("Producer.ProductionHost");
     videoHost = MirConfig.getProp("Producer.VideoHost");
@@ -231,6 +233,7 @@ public final class HTMLTemplateProcessor {
     // values in the templates. -mh
                // put standard configuration into tempalteRootmodel
                SimpleHash configHash = new SimpleHash();
+               configHash.put("defEncoding", new SimpleScalar(defEncoding));
                configHash.put("producerDocRoot", new SimpleScalar(producerDocRoot));
                configHash.put("storageRoot", new SimpleScalar(producerStorageRoot));
     configHash.put("productionHost", new SimpleScalar(productionHost));
index 9f56efc..c04e992 100755 (executable)
@@ -562,9 +562,8 @@ public class Database implements StorageObject {
                                // alle durchlaufen bis nix mehr da
                                theType = metadataTypes[i];
                                if (theType == java.sql.Types.LONGVARBINARY) {
-                                       InputStream us = rs.getAsciiStream(i + 1);
-                                       if (us != null) {
-                                               InputStreamReader is = new InputStreamReader(us);
+                                       InputStreamReader is = (InputStreamReader)rs.getCharacterStream(i + 1);
+                                       if (is != null) {
                                                char[] data = new char[32768];
                                                StringBuffer theResultString = new StringBuffer();
                                                int len;
index b641371..28e42da 100755 (executable)
@@ -74,27 +74,32 @@ abstract public class Producer {
                        File f = new File(producerStorageRoot + filename);
                        File dir = new File(f.getParent());
                        dir.mkdirs();
-                       FileWriter outputFile = new FileWriter(f);
+                       // it's important that we set the desired encoding. It should be UTF8
+      // not the platform default.
+      OutputStreamWriter outputFileStream =
+        new OutputStreamWriter(new FileOutputStream(f),
+                               MirConfig.getProp("Mir.DefaultEncoding"));
                        PrintWriter outStream;
                        if (compressed==true) {
-                               outStream = new LineFilterWriter(outputFile);
+                               outStream = new LineFilterWriter(outputFileStream);
                        } else {
-                               outStream = new PrintWriter(outputFile);
+                               outStream = new PrintWriter(outputFileStream);
                        }
 
                        HTMLTemplateProcessor.process(null,template, model, outStream,null);
-                       outputFile.close();
+                       outputFileStream.close();
                        outStream.close();
 
                        printHTML(htmlout, "Produced <a href=\"" + producerProductionHost+
                         filename + "\">" + filename + "</a>");
                        //theLog.printInfo("Produced: " + producerStorageRoot + filename);
-                       //theLog.printDebugInfo("free mem:" + java.lang.Runtime.getRuntime().freeMemory());
+       //theLog.printDebugInfo("free mem:" + java.lang.Runtime.getRuntime().freeMemory());
       //theLog.printDebugInfo("total mem:" + java.lang.Runtime.getRuntime().totalMemory());
                        return true;
 
                } catch(IOException exception){
                        logHTML(htmlout, "Producer: File could not be written " + filename);
+      System.out.println(exception.toString());
                        return false;
                } catch(HTMLParseException exception){
                        logHTML(htmlout,"Producer: Error in HTML-parsing: " + filename);
index 24dd61d..0e529b6 100755 (executable)
@@ -1,7 +1,7 @@
 <html>
   <head>
     <title>${lang("start.htmltitle")}</title>
-    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+    <meta http-equiv="Content-Type" content="text/html; charset=${config.defEncoding}">
   </head>
 
 <body bgcolor="#FFFFFF" link="#666666" vlink="#990000" alink="#990000">
index 58f41c8..53e0026 100755 (executable)
@@ -1,7 +1,7 @@
 <html>
 <head>
 <title>${lang("producer.content.htmltitle")}${content.title}</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=${config.defEncoding}">
 <link rel="stylesheet" href="/style/mir.css" type="text/css">
                        <if data.content.to_media_images>
                 <meta name="keywords" content="images"></meta>
index 3e137cf..74b3ac7 100755 (executable)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding=${config.defEncoding}?>
 
 <rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
index 595f9cc..407f340 100755 (executable)
@@ -1,7 +1,7 @@
 <html>
 <head>
 <title>${lang("producer.openposting.htmltitle")}${topic.title}</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=${config.defEncoding}">
 <link rel="stylesheet" href="/style/mir.css" type="text/css">
 </head>
 
index f738c49..3483698 100755 (executable)
@@ -1,7 +1,7 @@
 <html>
 <head>
 <title>${lang("producer.startpage.htmltitle")}</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=${config.defEncoding}">
 <link rel="stylesheet" href="/style/mir.css" type="text/css">
 </head>
 
index 1da84cd..aaa02a7 100755 (executable)
@@ -1,7 +1,7 @@
 <html>
 <head>
 <title>${lang("producer.topiclist.htmltitle")}${topic.title}</title>
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<meta http-equiv="Content-Type" content="text/html; charset=${config.defEncoding}">
 <link rel="stylesheet" href="/style/mir.css" type="text/css">
 </head>
 
index 3787604..601ebb9 100755 (executable)
@@ -4,7 +4,7 @@
 
 <xsl:output
                   method="xml"
-                  encoding="iso-8859-1"
+                  encoding="${config.defEncoding}"
                   omit-xml-declaration="yes"
                   doctype-public="-//WAPFORUM//DTD WML 1.1//EN"
                   doctype-system="http://www.wapforum.org/DTD/wml_1.1.xml"