Open Source Repository

Home /xom/xom-1.2.5 | Repository Home



nu/xom/ISOHebrewWriter.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-8, ASCII plus Hebrew
 </p>
 
 @author Elliotte Rusty Harold
 @version 1.0
 *
 */
class ISOHebrewWriter extends TextWriter {

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

    /**
     @see nu.xom.TextWriter#needsEscaping(char)
     */
    boolean needsEscaping(char c) { 
        if (c <= 0xA0return false;        
        switch (c) { // characters shared with Latin-1
            case 0x00A2return false// CENT SIGN
            case 0x00A3return false// POUND SIGN
            case 0x00A4return false// CURRENCY SIGN
            case 0x00A5return false// YEN SIGN
            case 0x00A6return false// BROKEN BAR
            case 0x00A7return false// SECTION SIGN
            case 0x00A8return false// DIAERESIS
            case 0x00A9return false// COPYRIGHT SIGN
            case 0x00ABreturn false// LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00ACreturn false// NOT SIGN
            case 0x00ADreturn false// SOFT HYPHEN
            case 0x00AEreturn false// REGISTERED SIGN
            // A bug in Java prevents a macron from being correctly 
            // output as the actual character in this encoding even
            // though it does exist in the ISO-8859-8 character set.
            // See JDC bug 4760496
            // http://developer.java.sun.com/developer/bugParade/bugs/4760496.html
            // They have marked this as fixed in Tiger (i.e. Java 1.5)
            // I'm not going to fix it here yet though, because I'd 
            // prefer XOM to work correctly with earlier versions of
            // of Java; and it's not incorrect to output a character 
            // reference even if you don't have to. It is an issue if a
            // macron is used in a a comment or a processing 
            // instruction though. The macron is not a name character
            // so that's not an issue though.
            case 0x00AFreturn true;  // MACRON
            case 0x00B0return false// DEGREE SIGN
            case 0x00B1return false// PLUS-MINUS SIGN
            case 0x00B2return false// SUPERSCRIPT TWO
            case 0x00B3return false// SUPERSCRIPT THREE
            case 0x00B4return false// ACUTE ACCENT
            case 0x00B5return false// MICRO SIGN
            case 0x00B6return false// PILCROW SIGN
            case 0x00B7return false// MIDDLE DOT
            case 0x00B8return false// CEDILLA
            case 0x00B9return false// SUPERSCRIPT ONE
            case 0x00BAreturn true;  // place holder to allow optimization of switch statement
            case 0x00BBreturn false// RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00BCreturn false// VULGAR FRACTION ONE QUARTER
            case 0x00BDreturn false// VULGAR FRACTION ONE HALF
            case 0x00BEreturn false// VULGAR FRACTION THREE QUARTERS
        }
        switch (c) {  // Unicode Hebrew block
            case 0x05D0return false// HEBREW LETTER ALEF
            case 0x05D1return false// HEBREW LETTER BET
            case 0x05D2return false// HEBREW LETTER GIMEL
            case 0x05D3return false// HEBREW LETTER DALET
            case 0x05D4return false// HEBREW LETTER HE
            case 0x05D5return false// HEBREW LETTER VAV
            case 0x05D6return false// HEBREW LETTER ZAYIN
            case 0x05D7return false// HEBREW LETTER HET
            case 0x05D8return false// HEBREW LETTER TET
            case 0x05D9return false// HEBREW LETTER YOD
            case 0x05DAreturn false// HEBREW LETTER FINAL KAF
            case 0x05DBreturn false// HEBREW LETTER KAF
            case 0x05DCreturn false// HEBREW LETTER LAMED
            case 0x05DDreturn false// HEBREW LETTER FINAL MEM
            case 0x05DEreturn false// HEBREW LETTER MEM
            case 0x05DFreturn false// HEBREW LETTER FINAL NUN
            case 0x05E0return false// HEBREW LETTER NUN
            case 0x05E1return false// HEBREW LETTER SAMEKH
            case 0x05E2return false// HEBREW LETTER AYIN
            case 0x05E3return false// HEBREW LETTER FINAL PE
            case 0x05E4return false// HEBREW LETTER PE
            case 0x05E5return false// HEBREW LETTER FINAL TSADI
            case 0x05E6return false// HEBREW LETTER TSADI
            case 0x05E7return false// HEBREW LETTER QOF
            case 0x05E8return false// HEBREW LETTER RESH
            case 0x05E9return false// HEBREW LETTER SHIN
            case 0x05EAreturn false// HEBREW LETTER TAV
        }
        
        switch (c) {  // a few random, out of order characters
            case 0x00D7return false// MULTIPLICATION SIGN
            case 0x00F7return false// DIVISION SIGN
            // A bug in Java prevents a LEFT-TO-RIGHT MARK 
            // and RIGHT-TO-LEFT MARK from being correctly output
            // as the actual character in this encoding even
            // though it does exist in the ISO-8859-8 character set.
            // See JDC bug 4758951
            // http://developer.java.sun.com/developer/bugParade/bugs/4758951.html
            // They have marked this as fixed in Tiger (i.e. Java 1.5)
            // case 0x200E: return false; // LEFT-TO-RIGHT MARK
            // case 0x200F: return false; // RIGHT-TO-LEFT MARK
            case 0x2017return false// DOUBLE LOW LINE
        }
        
        return true;
        
    }

}