Open Source Repository

Home /xom/xom-1.1 | Repository Home



nu/xom/ISOGreekWriter.java
/* Copyright 2002, 2003 Elliotte Rusty Harold
   
   This library is free software; you can redistribute it and/or modify
   it under the terms of version 2.1 of the GNU Lesser General Public 
   License as published by the Free Software Foundation.
   
   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
   GNU Lesser General Public License for more details.
   
   You should have received a copy of the GNU Lesser General Public
   License along with this library; if not, write to the 
   Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
   Boston, MA 02111-1307  USA
   
   You can contact Elliotte Rusty Harold by sending e-mail to
   [email protected]. Please include the word "XOM" in the
   subject line. The XOM home page is located at http://www.xom.nu/
*/

package nu.xom;

import java.io.Writer;

/**
 <p>
 *   ISO 8859-7, ASCII plus Greek
 </p>
 
 @author Elliotte Rusty Harold
 @version 1.1b2
 *
 */
class ISOGreekWriter extends TextWriter {

    ISOGreekWriter(Writer out, String encoding) {
        super(out, encoding);
    }

    /**
     @see nu.xom.TextWriter#needsEscaping(char)
     */
    boolean needsEscaping(char c) {
        if (c < 127return false;     
        switch (c) { // Greek
            case 0x0384return false// GREEK TONOS
            case 0x0385return false// GREEK DIALYTIKA TONOS
            case 0x0386return false// GREEK CAPITAL LETTER ALPHA WITH TONOS
            case 0x0387return true;  // place holder to enable table lookup
            case 0x0388return false// GREEK CAPITAL LETTER EPSILON WITH TONOS
            case 0x0389return false// GREEK CAPITAL LETTER ETA WITH TONOS
            case 0x038Areturn false// GREEK CAPITAL LETTER IOTA WITH TONOS
            case 0x038Breturn true;  // place holder to enable table lookup
            case 0x038Creturn false// GREEK CAPITAL LETTER OMICRON WITH TONOS
            case 0x038Dreturn true;  // place holder to enable table lookup
            case 0x038Ereturn false// GREEK CAPITAL LETTER UPSILON WITH TONOS
            case 0x038Freturn false// GREEK CAPITAL LETTER OMEGA WITH TONOS
            case 0x0390return false// GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
            case 0x0391return false// GREEK CAPITAL LETTER ALPHA
            case 0x0392return false// GREEK CAPITAL LETTER BETA
            case 0x0393return false// GREEK CAPITAL LETTER GAMMA
            case 0x0394return false// GREEK CAPITAL LETTER DELTA
            case 0x0395return false// GREEK CAPITAL LETTER EPSILON
            case 0x0396return false// GREEK CAPITAL LETTER ZETA
            case 0x0397return false// GREEK CAPITAL LETTER ETA
            case 0x0398return false// GREEK CAPITAL LETTER THETA
            case 0x0399return false// GREEK CAPITAL LETTER IOTA
            case 0x039Areturn false// GREEK CAPITAL LETTER KAPPA
            case 0x039Breturn false// GREEK CAPITAL LETTER LAMDA
            case 0x039Creturn false// GREEK CAPITAL LETTER MU
            case 0x039Dreturn false// GREEK CAPITAL LETTER NU
            case 0x039Ereturn false// GREEK CAPITAL LETTER XI
            case 0x039Freturn false// GREEK CAPITAL LETTER OMICRON
            case 0x03A0return false// GREEK CAPITAL LETTER PI
            case 0x03A1return false// GREEK CAPITAL LETTER RHO
            case 0x03A2return true;  // place holder to enable table lookup
            case 0x03A3return false// GREEK CAPITAL LETTER SIGMA
            case 0x03A4return false// GREEK CAPITAL LETTER TAU
            case 0x03A5return false// GREEK CAPITAL LETTER UPSILON
            case 0x03A6return false// GREEK CAPITAL LETTER PHI
            case 0x03A7return false// GREEK CAPITAL LETTER CHI
            case 0x03A8return false// GREEK CAPITAL LETTER PSI
            case 0x03A9return false// GREEK CAPITAL LETTER OMEGA
            case 0x03AAreturn false// GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
            case 0x03ABreturn false// GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
            case 0x03ACreturn false// GREEK SMALL LETTER ALPHA WITH TONOS
            case 0x03ADreturn false// GREEK SMALL LETTER EPSILON WITH TONOS
            case 0x03AEreturn false// GREEK SMALL LETTER ETA WITH TONOS
            case 0x03AFreturn false// GREEK SMALL LETTER IOTA WITH TONOS
            case 0x03B0return false// GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
            case 0x03B1return false// GREEK SMALL LETTER ALPHA
            case 0x03B2return false// GREEK SMALL LETTER BETA
            case 0x03B3return false// GREEK SMALL LETTER GAMMA
            case 0x03B4return false// GREEK SMALL LETTER DELTA
            case 0x03B5return false// GREEK SMALL LETTER EPSILON
            case 0x03B6return false// GREEK SMALL LETTER ZETA
            case 0x03B7return false// GREEK SMALL LETTER ETA
            case 0x03B8return false// GREEK SMALL LETTER THETA
            case 0x03B9return false// GREEK SMALL LETTER IOTA
            case 0x03BAreturn false// GREEK SMALL LETTER KAPPA
            case 0x03BBreturn false// GREEK SMALL LETTER LAMDA
            case 0x03BCreturn false// GREEK SMALL LETTER MU
            case 0x03BDreturn false// GREEK SMALL LETTER NU
            case 0x03BEreturn false// GREEK SMALL LETTER XI
            case 0x03BFreturn false// GREEK SMALL LETTER OMICRON
            case 0x03C0return false// GREEK SMALL LETTER PI
            case 0x03C1return false// GREEK SMALL LETTER RHO
            case 0x03C2return false// GREEK SMALL LETTER FINAL SIGMA
            case 0x03C3return false// GREEK SMALL LETTER SIGMA
            case 0x03C4return false// GREEK SMALL LETTER TAU
            case 0x03C5return false// GREEK SMALL LETTER UPSILON
            case 0x03C6return false// GREEK SMALL LETTER PHI
            case 0x03C7return false// GREEK SMALL LETTER CHI
            case 0x03C8return false// GREEK SMALL LETTER PSI
            case 0x03C9return false// GREEK SMALL LETTER OMEGA
            case 0x03CAreturn false// GREEK SMALL LETTER IOTA WITH DIALYTIKA
            case 0x03CBreturn false// GREEK SMALL LETTER UPSILON WITH DIALYTIKA
            case 0x03CCreturn false// GREEK SMALL LETTER OMICRON WITH TONOS
            case 0x03CDreturn false// GREEK SMALL LETTER UPSILON WITH TONOS
            case 0x03CEreturn false// GREEK SMALL LETTER OMEGA WITH TONOS
        }
        switch (c) { // overlap with Latin-1
            case 0x00A0return false// non-breaking space
            case 0x00A1return true;  // place holder to enable table lookup
            case 0x00A2return true;  // place holder to enable table lookup
            case 0x00A3return false// POUND SIGN
            case 0x00A4return true;  // place holder to enable table lookup
            case 0x00A5return true;  // place holder to enable table lookup
            case 0x00A6return false// BROKEN BAR
            case 0x00A7return false// SECTION SIGN
            case 0x00A8return false// DIAERESIS
            case 0x00A9return false// COPYRIGHT SIGN
            case 0x00AAreturn true;  // place holder to enable table lookup
            case 0x00ABreturn false// LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00ACreturn false// NOT SIGN
            case 0x00ADreturn false// SOFT HYPHEN
            case 0x00AEreturn true;  // place holder to enable table lookup
            case 0x00AFreturn true;  // place holder to enable table lookup
            case 0x00B0return false// DEGREE SIGN
            case 0x00B1return false// PLUS-MINUS SIGN
            case 0x00B2return false// SUPERSCRIPT TWO
            case 0x00B3return false// SUPERSCRIPT THREE
            case 0x00B4return true;  // place holder to enable table lookup
            case 0x00B5return true;  // place holder to enable table lookup
            case 0x00B6return true;  // place holder to enable table lookup
            case 0x00B7return false// MIDDLE DOT
            case 0x00B8return true;  // place holder to enable table lookup
            case 0x00B9return true;  // place holder to enable table lookup
            case 0x00BAreturn true;  // place holder to enable table lookup
            case 0x00BBreturn false// RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00BCreturn true;  // place holder to enable table lookup
            case 0x00BDreturn false// VULGAR FRACTION ONE HALF
        }
        switch (c) { // assorted characters
            case 0x2015return false// HORIZONTAL BAR
            // A bug in Java 1.4 and 1.3 prevents a LEFT and RIGHT 
            // SINGLE QUOTATION MARKs
            // from being correctly output
            // as the actual character in this encoding
            // even though it does exist in the 
            // ISO-8859-7 character set.
            // case 0x2018: return false; // LEFT SINGLE QUOTATION MARK
            // case 0x2019: return false; // RIGHT SINGLE QUOTATION MARK        
        }
        return true;
    }

}