~vcs-imports/xena/trunk

« back to all changes in this revision

Viewing changes to src/nu/xom/Latin9Writer.java

  • Committer: matthewoliver
  • Date: 2009-12-10 03:18:07 UTC
  • Revision ID: vcs-imports@canonical.com-20091210031807-l086qguzdlljtkl9
Merged Xena Testing into Xena Stable for the Xena 5 release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2002, 2003 Elliotte Rusty Harold
 
2
   
 
3
   This library is free software; you can redistribute it and/or modify
 
4
   it under the terms of version 2.1 of the GNU Lesser General Public 
 
5
   License as published by the Free Software Foundation.
 
6
   
 
7
   This library is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 
10
   GNU Lesser General Public License for more details.
 
11
   
 
12
   You should have received a copy of the GNU Lesser General Public
 
13
   License along with this library; if not, write to the 
 
14
   Free Software Foundation, Inc., 59 Temple Place, Suite 330, 
 
15
   Boston, MA 02111-1307  USA
 
16
   
 
17
   You can contact Elliotte Rusty Harold by sending e-mail to
 
18
   elharo@metalab.unc.edu. Please include the word "XOM" in the
 
19
   subject line. The XOM home page is located at http://www.xom.nu/
 
20
*/
 
21
 
 
22
package nu.xom;
 
23
 
 
24
import java.io.Writer;
 
25
 
 
26
/**
 
27
 * <p>
 
28
 *  ISO 8859-9 for Western Europe. Includes the Euro sign and
 
29
 *  several uncommon French letters. otherwise the same as 
 
30
 *  Latin-1. 
 
31
 * </p>
 
32
 * 
 
33
 * @author Elliotte Rusty Harold
 
34
 * @version 1.0
 
35
 *
 
36
 */
 
37
class Latin9Writer extends TextWriter {
 
38
 
 
39
    /**
 
40
     * <p>
 
41
     *   Creates a new <code>TextWriter</code> for the
 
42
     *   ISO-8859-15 (Latin-9) character encoding.
 
43
     * </p>
 
44
    *
 
45
     * @param out the <code>Writer</code> on which the text will be written
 
46
     * @param encoding the character set used by the <code>Writer</code>
 
47
     */
 
48
    Latin9Writer(Writer out, String encoding) {
 
49
        super(out, encoding);
 
50
    }
 
51
 
 
52
    /**
 
53
     * <p>
 
54
     *   Returns true if and only if this character 
 
55
     *   needs to be replaced by a character reference when
 
56
     *   output in this encoding.
 
57
     * </p>
 
58
     * 
 
59
     * 
 
60
     * @see nu.xom.TextWriter#needsEscaping(char)
 
61
     */
 
62
    boolean needsEscaping(char c) {
 
63
        if (c <= 0xA3 ) return false;      
 
64
        if (c == 0x20AC) return false; // EURO SIGN
 
65
        
 
66
        switch (c) {  // Latin-1 overlap
 
67
            case 0x00A5: return false; // YEN SIGN
 
68
            case 0x00A6: return true;  // place holder to enable table lookup
 
69
            case 0x00A7: return false; // SECTION SIGN
 
70
            case 0x00A8: return true;  // place holder to enable table lookup
 
71
            case 0x00A9: return false; // COPYRIGHT SIGN
 
72
            case 0x00AA: return false; // FEMININE ORDINAL INDICATOR
 
73
            case 0x00AB: return false; // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
 
74
            case 0x00AC: return false; // NOT SIGN
 
75
            case 0x00AD: return false; // SOFT HYPHEN
 
76
            case 0x00AE: return false; // REGISTERED SIGN
 
77
            case 0x00AF: return false; // MACRON
 
78
            case 0x00B0: return false; // DEGREE SIGN
 
79
            case 0x00B1: return false; // PLUS-MINUS SIGN
 
80
            case 0x00B2: return false; // SUPERSCRIPT TWO
 
81
            case 0x00B3: return false; // SUPERSCRIPT THREE
 
82
            case 0x00B4: return true;  // place holder to enable table lookup
 
83
            case 0x00B5: return false; // MICRO SIGN
 
84
            case 0x00B6: return false; // PILCROW SIGN
 
85
            case 0x00B7: return false; // MIDDLE DOT
 
86
            case 0x00B8: return true;  // place holder to enable table lookup
 
87
            case 0x00B9: return false; // SUPERSCRIPT ONE
 
88
            case 0x00BA: return false; // MASCULINE ORDINAL INDICATOR
 
89
            case 0x00BB: return false; // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
 
90
            case 0x00BC: return true;  // place holder to enable table lookup
 
91
            case 0x00BD: return true;  // place holder to enable table lookup
 
92
            case 0x00BE: return true;  // place holder to enable table lookup
 
93
            case 0x00BF: return false; // INVERTED QUESTION MARK
 
94
            case 0x00C0: return false; // LATIN CAPITAL LETTER A WITH GRAVE
 
95
            case 0x00C1: return false; // LATIN CAPITAL LETTER A WITH ACUTE
 
96
            case 0x00C2: return false; // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
 
97
            case 0x00C3: return false; // LATIN CAPITAL LETTER A WITH TILDE
 
98
            case 0x00C4: return false; // LATIN CAPITAL LETTER A WITH DIAERESIS
 
99
            case 0x00C5: return false; // LATIN CAPITAL LETTER A WITH RING ABOVE
 
100
            case 0x00C6: return false; // LATIN CAPITAL LETTER AE
 
101
            case 0x00C7: return false; // LATIN CAPITAL LETTER C WITH CEDILLA
 
102
            case 0x00C8: return false; // LATIN CAPITAL LETTER E WITH GRAVE
 
103
            case 0x00C9: return false; // LATIN CAPITAL LETTER E WITH ACUTE
 
104
            case 0x00CA: return false; // LATIN CAPITAL LETTER E WITH CIRCUMFLEX
 
105
            case 0x00CB: return false; // LATIN CAPITAL LETTER E WITH DIAERESIS
 
106
            case 0x00CC: return false; // LATIN CAPITAL LETTER I WITH GRAVE
 
107
            case 0x00CD: return false; // LATIN CAPITAL LETTER I WITH ACUTE
 
108
            case 0x00CE: return false; // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
 
109
            case 0x00CF: return false; // LATIN CAPITAL LETTER I WITH DIAERESIS
 
110
            case 0x00D0: return false; // LATIN CAPITAL LETTER ETH
 
111
            case 0x00D1: return false; // LATIN CAPITAL LETTER N WITH TILDE
 
112
            case 0x00D2: return false; // LATIN CAPITAL LETTER O WITH GRAVE
 
113
            case 0x00D3: return false; // LATIN CAPITAL LETTER O WITH ACUTE
 
114
            case 0x00D4: return false; // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
 
115
            case 0x00D5: return false; // LATIN CAPITAL LETTER O WITH TILDE
 
116
            case 0x00D6: return false; // LATIN CAPITAL LETTER O WITH DIAERESIS
 
117
            case 0x00D7: return false; // MULTIPLICATION SIGN
 
118
            case 0x00D8: return false; // LATIN CAPITAL LETTER O WITH STROKE
 
119
            case 0x00D9: return false; // LATIN CAPITAL LETTER U WITH GRAVE
 
120
            case 0x00DA: return false; // LATIN CAPITAL LETTER U WITH ACUTE
 
121
            case 0x00DB: return false; // LATIN CAPITAL LETTER U WITH CIRCUMFLEX
 
122
            case 0x00DC: return false; // LATIN CAPITAL LETTER U WITH DIAERESIS
 
123
            case 0x00DD: return false; // LATIN CAPITAL LETTER Y WITH ACUTE
 
124
            case 0x00DE: return false; // LATIN CAPITAL LETTER THORN
 
125
            case 0x00DF: return false; // LATIN SMALL LETTER SHARP S
 
126
            case 0x00E0: return false; // LATIN SMALL LETTER A WITH GRAVE
 
127
            case 0x00E1: return false; // LATIN SMALL LETTER A WITH ACUTE
 
128
            case 0x00E2: return false; // LATIN SMALL LETTER A WITH CIRCUMFLEX
 
129
            case 0x00E3: return false; // LATIN SMALL LETTER A WITH TILDE
 
130
            case 0x00E4: return false; // LATIN SMALL LETTER A WITH DIAERESIS
 
131
            case 0x00E5: return false; // LATIN SMALL LETTER A WITH RING ABOVE
 
132
            case 0x00E6: return false; // LATIN SMALL LETTER AE
 
133
            case 0x00E7: return false; // LATIN SMALL LETTER C WITH CEDILLA
 
134
            case 0x00E8: return false; // LATIN SMALL LETTER E WITH GRAVE
 
135
            case 0x00E9: return false; // LATIN SMALL LETTER E WITH ACUTE
 
136
            case 0x00EA: return false; // LATIN SMALL LETTER E WITH CIRCUMFLEX
 
137
            case 0x00EB: return false; // LATIN SMALL LETTER E WITH DIAERESIS
 
138
            case 0x00EC: return false; // LATIN SMALL LETTER I WITH GRAVE
 
139
            case 0x00ED: return false; // LATIN SMALL LETTER I WITH ACUTE
 
140
            case 0x00EE: return false; // LATIN SMALL LETTER I WITH CIRCUMFLEX
 
141
            case 0x00EF: return false; // LATIN SMALL LETTER I WITH DIAERESIS
 
142
            case 0x00F0: return false; // LATIN SMALL LETTER ETH
 
143
            case 0x00F1: return false; // LATIN SMALL LETTER N WITH TILDE
 
144
            case 0x00F2: return false; // LATIN SMALL LETTER O WITH GRAVE
 
145
            case 0x00F3: return false; // LATIN SMALL LETTER O WITH ACUTE
 
146
            case 0x00F4: return false; // LATIN SMALL LETTER O WITH CIRCUMFLEX
 
147
            case 0x00F5: return false; // LATIN SMALL LETTER O WITH TILDE
 
148
            case 0x00F6: return false; // LATIN SMALL LETTER O WITH DIAERESIS
 
149
            case 0x00F7: return false; // DIVISION SIGN
 
150
            case 0x00F8: return false; // LATIN SMALL LETTER O WITH STROKE
 
151
            case 0x00F9: return false; // LATIN SMALL LETTER U WITH GRAVE
 
152
            case 0x00FA: return false; // LATIN SMALL LETTER U WITH ACUTE
 
153
            case 0x00FB: return false; // LATIN SMALL LETTER U WITH CIRCUMFLEX
 
154
            case 0x00FC: return false; // LATIN SMALL LETTER U WITH DIAERESIS
 
155
            case 0x00FD: return false; // LATIN SMALL LETTER Y WITH ACUTE
 
156
            case 0x00FE: return false; // LATIN SMALL LETTER THORN
 
157
            case 0x00FF: return false; // LATIN SMALL LETTER Y WITH DIAERESIS
 
158
        }
 
159
        switch (c) { // uncommon French letters
 
160
            case 0x0152: return false; // LATIN CAPITAL LIGATURE OE
 
161
            case 0x0153: return false; // LATIN SMALL LIGATURE OE
 
162
            case 0x0154: return true;  // place holder to enable table lookup
 
163
            case 0x0155: return true;  // place holder to enable table lookup
 
164
            case 0x0156: return true;  // place holder to enable table lookup
 
165
            case 0x0157: return true;  // place holder to enable table lookup
 
166
            case 0x0158: return true;  // place holder to enable table lookup
 
167
            case 0x0159: return true;  // place holder to enable table lookup
 
168
            case 0x015A: return true;  // place holder to enable table lookup
 
169
            case 0x015B: return true;  // place holder to enable table lookup
 
170
            case 0x015C: return true;  // place holder to enable table lookup
 
171
            case 0x015D: return true;  // place holder to enable table lookup
 
172
            case 0x015E: return true;  // place holder to enable table lookup
 
173
            case 0x015F: return true;  // place holder to enable table lookup
 
174
            case 0x0160: return false; // LATIN CAPITAL LETTER S WITH CARON
 
175
            case 0x0161: return false; // LATIN SMALL LETTER S WITH CARON
 
176
            case 0x0162: return true;  // place holder to enable table lookup
 
177
            case 0x0163: return true;  // place holder to enable table lookup
 
178
            case 0x0164: return true;  // place holder to enable table lookup
 
179
            case 0x0165: return true;  // place holder to enable table lookup
 
180
            case 0x0166: return true;  // place holder to enable table lookup
 
181
            case 0x0167: return true;  // place holder to enable table lookup
 
182
            case 0x0168: return true;  // place holder to enable table lookup
 
183
            case 0x0169: return true;  // place holder to enable table lookup
 
184
            case 0x016A: return true;  // place holder to enable table lookup
 
185
            case 0x016B: return true;  // place holder to enable table lookup
 
186
            case 0x016C: return true;  // place holder to enable table lookup
 
187
            case 0x016D: return true;  // place holder to enable table lookup
 
188
            case 0x016E: return true;  // place holder to enable table lookup
 
189
            case 0x016F: return true;  // place holder to enable table lookup
 
190
            case 0x0170: return true;  // place holder to enable table lookup
 
191
            case 0x0171: return true;  // place holder to enable table lookup
 
192
            case 0x0172: return true;  // place holder to enable table lookup
 
193
            case 0x0173: return true;  // place holder to enable table lookup
 
194
            case 0x0174: return true;  // place holder to enable table lookup
 
195
            case 0x0175: return true;  // place holder to enable table lookup
 
196
            case 0x0176: return true;  // place holder to enable table lookup
 
197
            case 0x0177: return true;  // place holder to enable table lookup
 
198
            case 0x0178: return false; // LATIN CAPITAL LETTER Y WITH DIAERESIS
 
199
            case 0x017D: return false; // LATIN CAPITAL LETTER Z WITH CARON
 
200
            case 0x017E: return false; // LATIN SMALL LETTER Z WITH CARON
 
201
        }
 
202
        
 
203
        return true;
 
204
        
 
205
    }
 
206
 
 
207
}
 
 
b'\\ No newline at end of file'