Open Source Repository

Home /xom/xom-1.1 | Repository Home



nu/xom/Latin9Writer.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-9 for Western Europe. Includes the Euro sign and
 *  several uncommon French letters. otherwise the same as 
 *  Latin-1. 
 </p>
 
 @author Elliotte Rusty Harold
 @version 1.0
 *
 */
class Latin9Writer extends TextWriter {

    /**
     <p>
     *   Creates a new <code>TextWriter</code> for the
     *   ISO-8859-15 (Latin-9) character encoding.
     </p>
    *
     @param out the <code>Writer</code> on which the text will be written
     @param encoding the character set used by the <code>Writer</code>
     */
    Latin9Writer(Writer out, String encoding) {
        super(out, encoding);
    }

    /**
     <p>
     *   Returns true if and only if this character 
     *   needs to be replaced by a character reference when
     *   output in this encoding.
     </p>
     
     
     @see nu.xom.TextWriter#needsEscaping(char)
     */
    boolean needsEscaping(char c) {
        if (c <= 0xA3 return false;      
        if (c == 0x20ACreturn false// EURO SIGN
        
        switch (c) {  // Latin-1 overlap
            case 0x00A5return false// YEN SIGN
            case 0x00A6return true;  // place holder to enable table lookup
            case 0x00A7return false// SECTION SIGN
            case 0x00A8return true;  // place holder to enable table lookup
            case 0x00A9return false// COPYRIGHT SIGN
            case 0x00AAreturn false// FEMININE ORDINAL INDICATOR
            case 0x00ABreturn false// LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00ACreturn false// NOT SIGN
            case 0x00ADreturn false// SOFT HYPHEN
            case 0x00AEreturn false// REGISTERED SIGN
            case 0x00AFreturn false// MACRON
            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 false// MICRO SIGN
            case 0x00B6return false// PILCROW SIGN
            case 0x00B7return false// MIDDLE DOT
            case 0x00B8return true;  // place holder to enable table lookup
            case 0x00B9return false// SUPERSCRIPT ONE
            case 0x00BAreturn false// MASCULINE ORDINAL INDICATOR
            case 0x00BBreturn false// RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
            case 0x00BCreturn true;  // place holder to enable table lookup
            case 0x00BDreturn true;  // place holder to enable table lookup
            case 0x00BEreturn true;  // place holder to enable table lookup
            case 0x00BFreturn false// INVERTED QUESTION MARK
            case 0x00C0return false// LATIN CAPITAL LETTER A WITH GRAVE
            case 0x00C1return false// LATIN CAPITAL LETTER A WITH ACUTE
            case 0x00C2return false// LATIN CAPITAL LETTER A WITH CIRCUMFLEX
            case 0x00C3return false// LATIN CAPITAL LETTER A WITH TILDE
            case 0x00C4return false// LATIN CAPITAL LETTER A WITH DIAERESIS
            case 0x00C5return false// LATIN CAPITAL LETTER A WITH RING ABOVE
            case 0x00C6return false// LATIN CAPITAL LETTER AE
            case 0x00C7return false// LATIN CAPITAL LETTER C WITH CEDILLA
            case 0x00C8return false// LATIN CAPITAL LETTER E WITH GRAVE
            case 0x00C9return false// LATIN CAPITAL LETTER E WITH ACUTE
            case 0x00CAreturn false// LATIN CAPITAL LETTER E WITH CIRCUMFLEX
            case 0x00CBreturn false// LATIN CAPITAL LETTER E WITH DIAERESIS
            case 0x00CCreturn false// LATIN CAPITAL LETTER I WITH GRAVE
            case 0x00CDreturn false// LATIN CAPITAL LETTER I WITH ACUTE
            case 0x00CEreturn false// LATIN CAPITAL LETTER I WITH CIRCUMFLEX
            case 0x00CFreturn false// LATIN CAPITAL LETTER I WITH DIAERESIS
            case 0x00D0return false// LATIN CAPITAL LETTER ETH
            case 0x00D1return false// LATIN CAPITAL LETTER N WITH TILDE
            case 0x00D2return false// LATIN CAPITAL LETTER O WITH GRAVE
            case 0x00D3return false// LATIN CAPITAL LETTER O WITH ACUTE
            case 0x00D4return false// LATIN CAPITAL LETTER O WITH CIRCUMFLEX
            case 0x00D5return false// LATIN CAPITAL LETTER O WITH TILDE
            case 0x00D6return false// LATIN CAPITAL LETTER O WITH DIAERESIS
            case 0x00D7return false// MULTIPLICATION SIGN
            case 0x00D8return false// LATIN CAPITAL LETTER O WITH STROKE
            case 0x00D9return false// LATIN CAPITAL LETTER U WITH GRAVE
            case 0x00DAreturn false// LATIN CAPITAL LETTER U WITH ACUTE
            case 0x00DBreturn false// LATIN CAPITAL LETTER U WITH CIRCUMFLEX
            case 0x00DCreturn false// LATIN CAPITAL LETTER U WITH DIAERESIS
            case 0x00DDreturn false// LATIN CAPITAL LETTER Y WITH ACUTE
            case 0x00DEreturn false// LATIN CAPITAL LETTER THORN
            case 0x00DFreturn false// LATIN SMALL LETTER SHARP S
            case 0x00E0return false// LATIN SMALL LETTER A WITH GRAVE
            case 0x00E1return false// LATIN SMALL LETTER A WITH ACUTE
            case 0x00E2return false// LATIN SMALL LETTER A WITH CIRCUMFLEX
            case 0x00E3return false// LATIN SMALL LETTER A WITH TILDE
            case 0x00E4return false// LATIN SMALL LETTER A WITH DIAERESIS
            case 0x00E5return false// LATIN SMALL LETTER A WITH RING ABOVE
            case 0x00E6return false// LATIN SMALL LETTER AE
            case 0x00E7return false// LATIN SMALL LETTER C WITH CEDILLA
            case 0x00E8return false// LATIN SMALL LETTER E WITH GRAVE
            case 0x00E9return false// LATIN SMALL LETTER E WITH ACUTE
            case 0x00EAreturn false// LATIN SMALL LETTER E WITH CIRCUMFLEX
            case 0x00EBreturn false// LATIN SMALL LETTER E WITH DIAERESIS
            case 0x00ECreturn false// LATIN SMALL LETTER I WITH GRAVE
            case 0x00EDreturn false// LATIN SMALL LETTER I WITH ACUTE
            case 0x00EEreturn false// LATIN SMALL LETTER I WITH CIRCUMFLEX
            case 0x00EFreturn false// LATIN SMALL LETTER I WITH DIAERESIS
            case 0x00F0return false// LATIN SMALL LETTER ETH
            case 0x00F1return false// LATIN SMALL LETTER N WITH TILDE
            case 0x00F2return false// LATIN SMALL LETTER O WITH GRAVE
            case 0x00F3return false// LATIN SMALL LETTER O WITH ACUTE
            case 0x00F4return false// LATIN SMALL LETTER O WITH CIRCUMFLEX
            case 0x00F5return false// LATIN SMALL LETTER O WITH TILDE
            case 0x00F6return false// LATIN SMALL LETTER O WITH DIAERESIS
            case 0x00F7return false// DIVISION SIGN
            case 0x00F8return false// LATIN SMALL LETTER O WITH STROKE
            case 0x00F9return false// LATIN SMALL LETTER U WITH GRAVE
            case 0x00FAreturn false// LATIN SMALL LETTER U WITH ACUTE
            case 0x00FBreturn false// LATIN SMALL LETTER U WITH CIRCUMFLEX
            case 0x00FCreturn false// LATIN SMALL LETTER U WITH DIAERESIS
            case 0x00FDreturn false// LATIN SMALL LETTER Y WITH ACUTE
            case 0x00FEreturn false// LATIN SMALL LETTER THORN
            case 0x00FFreturn false// LATIN SMALL LETTER Y WITH DIAERESIS
        }
        switch (c) { // uncommon French letters
            case 0x0152return false// LATIN CAPITAL LIGATURE OE
            case 0x0153return false// LATIN SMALL LIGATURE OE
            case 0x0154return true;  // place holder to enable table lookup
            case 0x0155return true;  // place holder to enable table lookup
            case 0x0156return true;  // place holder to enable table lookup
            case 0x0157return true;  // place holder to enable table lookup
            case 0x0158return true;  // place holder to enable table lookup
            case 0x0159return true;  // place holder to enable table lookup
            case 0x015Areturn true;  // place holder to enable table lookup
            case 0x015Breturn true;  // place holder to enable table lookup
            case 0x015Creturn true;  // place holder to enable table lookup
            case 0x015Dreturn true;  // place holder to enable table lookup
            case 0x015Ereturn true;  // place holder to enable table lookup
            case 0x015Freturn true;  // place holder to enable table lookup
            case 0x0160return false// LATIN CAPITAL LETTER S WITH CARON
            case 0x0161return false// LATIN SMALL LETTER S WITH CARON
            case 0x0162return true;  // place holder to enable table lookup
            case 0x0163return true;  // place holder to enable table lookup
            case 0x0164return true;  // place holder to enable table lookup
            case 0x0165return true;  // place holder to enable table lookup
            case 0x0166return true;  // place holder to enable table lookup
            case 0x0167return true;  // place holder to enable table lookup
            case 0x0168return true;  // place holder to enable table lookup
            case 0x0169return true;  // place holder to enable table lookup
            case 0x016Areturn true;  // place holder to enable table lookup
            case 0x016Breturn true;  // place holder to enable table lookup
            case 0x016Creturn true;  // place holder to enable table lookup
            case 0x016Dreturn true;  // place holder to enable table lookup
            case 0x016Ereturn true;  // place holder to enable table lookup
            case 0x016Freturn true;  // place holder to enable table lookup
            case 0x0170return true;  // place holder to enable table lookup
            case 0x0171return true;  // place holder to enable table lookup
            case 0x0172return true;  // place holder to enable table lookup
            case 0x0173return true;  // place holder to enable table lookup
            case 0x0174return true;  // place holder to enable table lookup
            case 0x0175return true;  // place holder to enable table lookup
            case 0x0176return true;  // place holder to enable table lookup
            case 0x0177return true;  // place holder to enable table lookup
            case 0x0178return false// LATIN CAPITAL LETTER Y WITH DIAERESIS
            case 0x017Dreturn false// LATIN CAPITAL LETTER Z WITH CARON
            case 0x017Ereturn false// LATIN SMALL LETTER Z WITH CARON
        }
        
        return true;
        
    }

}