Open Source Repository

Home /xom/xom-1.1 | Repository Home



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

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

    /**
     @see nu.xom.TextWriter#needsEscaping(char)
     */
    boolean needsEscaping(char c) {
        if (c <= 0xA0return false;        
        switch (c) {
            case 0x060Creturn false// ARABIC COMMA
            case 0x060Dreturn true;  // place holder to allow table lookup                        
            case 0x060Ereturn true;  // place holder to allow table lookup                        
            case 0x060Freturn true;  // place holder to allow table lookup                        
            case 0x0610return true;  // place holder to allow table lookup                        
            case 0x0611return true;  // place holder to allow table lookup                        
            case 0x0612return true;  // place holder to allow table lookup                        
            case 0x0613return true;  // place holder to allow table lookup                        
            case 0x0614return true;  // place holder to allow table lookup                        
            case 0x0615return true;  // place holder to allow table lookup                        
            case 0x0616return true;  // place holder to allow table lookup                        
            case 0x0617return true;  // place holder to allow table lookup                        
            case 0x0618return true;  // place holder to allow table lookup                        
            case 0x0619return true;  // place holder to allow table lookup                        
            case 0x061Areturn true;  // place holder to allow table lookup                        
            case 0x061Breturn false// ARABIC SEMICOLON
            case 0x061Creturn true;  // place holder to allow table lookup            
            case 0x061Dreturn true;  // place holder to allow table lookup            
            case 0x061Ereturn true;  // place holder to allow table lookup            
            case 0x061Freturn false// ARABIC QUESTION MARK
            case 0x0620return true;  // place holder to allow table lookup
            case 0x0621return false// ARABIC LETTER HAMZA
            case 0x0622return false// ARABIC LETTER ALEF WITH MADDA ABOVE
            case 0x0623return false// ARABIC LETTER ALEF WITH HAMZA ABOVE
            case 0x0624return false// ARABIC LETTER WAW WITH HAMZA ABOVE
            case 0x0625return false// ARABIC LETTER ALEF WITH HAMZA BELOW
            case 0x0626return false// ARABIC LETTER YEH WITH HAMZA ABOVE
            case 0x0627return false// ARABIC LETTER ALEF
            case 0x0628return false// ARABIC LETTER BEH
            case 0x0629return false// ARABIC LETTER TEH MARBUTA
            case 0x062Areturn false// ARABIC LETTER TEH
            case 0x062Breturn false// ARABIC LETTER THEH
            case 0x062Creturn false// ARABIC LETTER JEEM
            case 0x062Dreturn false// ARABIC LETTER HAH
            case 0x062Ereturn false// ARABIC LETTER KHAH
            case 0x062Freturn false// ARABIC LETTER DAL
            case 0x0630return false// ARABIC LETTER THAL
            case 0x0631return false// ARABIC LETTER REH
            case 0x0632return false// ARABIC LETTER ZAIN
            case 0x0633return false// ARABIC LETTER SEEN
            case 0x0634return false// ARABIC LETTER SHEEN
            case 0x0635return false// ARABIC LETTER SAD
            case 0x0636return false// ARABIC LETTER DAD
            case 0x0637return false// ARABIC LETTER TAH
            case 0x0638return false// ARABIC LETTER ZAH
            case 0x0639return false// ARABIC LETTER AIN
            case 0x063Areturn false// ARABIC LETTER GHAIN
            case 0x063Breturn true;  // place holder to allow table lookup                        
            case 0x063Creturn true;  // place holder to allow table lookup                        
            case 0x063Dreturn true;  // place holder to allow table lookup                        
            case 0x063Ereturn true;  // place holder to allow table lookup                        
            case 0x063Freturn true;  // place holder to allow table lookup                        
            case 0x0640return false// ARABIC TATWEEL
            case 0x0641return false// ARABIC LETTER FEH
            case 0x0642return false// ARABIC LETTER QAF
            case 0x0643return false// ARABIC LETTER KAF
            case 0x0644return false// ARABIC LETTER LAM
            case 0x0645return false// ARABIC LETTER MEEM
            case 0x0646return false// ARABIC LETTER NOON
            case 0x0647return false// ARABIC LETTER HEH
            case 0x0648return false// ARABIC LETTER WAW
            case 0x0649return false// ARABIC LETTER ALEF MAKSURA
            case 0x064Areturn false// ARABIC LETTER YEH
            case 0x064Breturn false// ARABIC FATHATAN
            case 0x064Creturn false// ARABIC DAMMATAN
            case 0x064Dreturn false// ARABIC KASRATAN
            case 0x064Ereturn false// ARABIC FATHA
            case 0x064Freturn false// ARABIC DAMMA
            case 0x0650return false// ARABIC KASRA
            case 0x0651return false// ARABIC SHADDA
            case 0x0652return false// ARABIC SUKUN
        }
        switch (c) { // random overlap with Latin-1
            case 0x00A4return false// CURRENCY SIGN
            case 0x00ADreturn false// SOFT HYPHEN
        }
        
        return true;
        
    }

}