knguyen     2004/09/01 14:11:36 CEST

  Modified files:        (Branch: JAHIA-4-0-BRANCH)
    src/java/org/jahia/utils/fileparsers CharsetDetection.java 
  Log:
  - use first probable charset instead of first found charset
  
  Revision  Changes    Path
  1.1.2.2   +16 -3     jahia/src/java/org/jahia/utils/fileparsers/CharsetDetection.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/src/java/org/jahia/utils/fileparsers/CharsetDetection.java.diff?r1=1.1.2.1&r2=1.1.2.2&f=h
  
  
  
  Index: CharsetDetection.java
  ===================================================================
  RCS file: 
/home/cvs/repository/jahia/src/java/org/jahia/utils/fileparsers/Attic/CharsetDetection.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- CharsetDetection.java     30 Aug 2004 13:39:44 -0000      1.1.2.1
  +++ CharsetDetection.java     1 Sep 2004 12:11:36 -0000       1.1.2.2
  @@ -91,7 +91,6 @@
           }
           nsDetector det = new nsDetector(lang);
           det.Init(this);
  -
           BufferedInputStream imp = new BufferedInputStream(ins);
   
           byte[] buf = new byte[1024];
  @@ -107,10 +106,20 @@
   
               // DoIt if non-ascii and not done yet.
               if (!isAscii && !done)
  -                done = det.DoIt(buf, len, false);
  +                done = det.DoIt(buf, len, true);
           }
           det.DataEnd();
   
  +        String[]charSets = det.getProbableCharsets();
  +        for ( int i=0; i<charSets.length ; i++ ){
  +            logger.debug(
  +                "Charset detection notification , PROBABLE CHARSET FOUND = "
  +                + charSets[i]);
  +        }
  +        if ( charSets.length>0 ){
  +            this.charSet = charSets[0]; // get the first
  +        }
  +
           return (isAscii?1:0);
       }
   
  @@ -121,9 +130,13 @@
        */
       public void Notify(String charset)
       {
  +        // We can't rely on this, we should prefer probableCharsets use.
  +
  +        /*
           this.charSet = charset;
           logger.debug("Charset detection notification , CHARSET FOUND = "
                        + charset);
  -   }
  +        */
  +    }
   
   }
  

Reply via email to