001: /* Copyright 2002, 2003 Elliotte Rusty Harold
002:
003: This library is free software; you can redistribute it and/or modify
004: it under the terms of version 2.1 of the GNU Lesser General Public
005: License as published by the Free Software Foundation.
006:
007: This library is distributed in the hope that it will be useful,
008: but WITHOUT ANY WARRANTY; without even the implied warranty of
009: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: GNU Lesser General Public License for more details.
011:
012: You should have received a copy of the GNU Lesser General Public
013: License along with this library; if not, write to the
014: Free Software Foundation, Inc., 59 Temple Place, Suite 330,
015: Boston, MA 02111-1307 USA
016:
017: You can contact Elliotte Rusty Harold by sending e-mail to
018: elharo@metalab.unc.edu. Please include the word "XOM" in the
019: subject line. The XOM home page is located at http://www.xom.nu/
020: */
021:
022: package nu.xom;
023:
024: import java.io.Writer;
025:
026: /**
027: * <p>
028: * ISO 8859-9 for Western Europe. Includes the Euro sign and
029: * several uncommon French letters. otherwise the same as
030: * Latin-1.
031: * </p>
032: *
033: * @author Elliotte Rusty Harold
034: * @version 1.0
035: *
036: */
037: class Latin9Writer extends TextWriter {
038:
039: /**
040: * <p>
041: * Creates a new <code>TextWriter</code> for the
042: * ISO-8859-15 (Latin-9) character encoding.
043: * </p>
044: *
045: * @param out the <code>Writer</code> on which the text will be written
046: * @param encoding the character set used by the <code>Writer</code>
047: */
048: Latin9Writer(Writer out, String encoding) {
049: super (out, encoding);
050: }
051:
052: /**
053: * <p>
054: * Returns true if and only if this character
055: * needs to be replaced by a character reference when
056: * output in this encoding.
057: * </p>
058: *
059: *
060: * @see nu.xom.TextWriter#needsEscaping(char)
061: */
062: boolean needsEscaping(char c) {
063: if (c <= 0xA3)
064: return false;
065: if (c == 0x20AC)
066: return false; // EURO SIGN
067:
068: switch (c) { // Latin-1 overlap
069: case 0x00A5:
070: return false; // YEN SIGN
071: case 0x00A6:
072: return true; // place holder to enable table lookup
073: case 0x00A7:
074: return false; // SECTION SIGN
075: case 0x00A8:
076: return true; // place holder to enable table lookup
077: case 0x00A9:
078: return false; // COPYRIGHT SIGN
079: case 0x00AA:
080: return false; // FEMININE ORDINAL INDICATOR
081: case 0x00AB:
082: return false; // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
083: case 0x00AC:
084: return false; // NOT SIGN
085: case 0x00AD:
086: return false; // SOFT HYPHEN
087: case 0x00AE:
088: return false; // REGISTERED SIGN
089: case 0x00AF:
090: return false; // MACRON
091: case 0x00B0:
092: return false; // DEGREE SIGN
093: case 0x00B1:
094: return false; // PLUS-MINUS SIGN
095: case 0x00B2:
096: return false; // SUPERSCRIPT TWO
097: case 0x00B3:
098: return false; // SUPERSCRIPT THREE
099: case 0x00B4:
100: return true; // place holder to enable table lookup
101: case 0x00B5:
102: return false; // MICRO SIGN
103: case 0x00B6:
104: return false; // PILCROW SIGN
105: case 0x00B7:
106: return false; // MIDDLE DOT
107: case 0x00B8:
108: return true; // place holder to enable table lookup
109: case 0x00B9:
110: return false; // SUPERSCRIPT ONE
111: case 0x00BA:
112: return false; // MASCULINE ORDINAL INDICATOR
113: case 0x00BB:
114: return false; // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
115: case 0x00BC:
116: return true; // place holder to enable table lookup
117: case 0x00BD:
118: return true; // place holder to enable table lookup
119: case 0x00BE:
120: return true; // place holder to enable table lookup
121: case 0x00BF:
122: return false; // INVERTED QUESTION MARK
123: case 0x00C0:
124: return false; // LATIN CAPITAL LETTER A WITH GRAVE
125: case 0x00C1:
126: return false; // LATIN CAPITAL LETTER A WITH ACUTE
127: case 0x00C2:
128: return false; // LATIN CAPITAL LETTER A WITH CIRCUMFLEX
129: case 0x00C3:
130: return false; // LATIN CAPITAL LETTER A WITH TILDE
131: case 0x00C4:
132: return false; // LATIN CAPITAL LETTER A WITH DIAERESIS
133: case 0x00C5:
134: return false; // LATIN CAPITAL LETTER A WITH RING ABOVE
135: case 0x00C6:
136: return false; // LATIN CAPITAL LETTER AE
137: case 0x00C7:
138: return false; // LATIN CAPITAL LETTER C WITH CEDILLA
139: case 0x00C8:
140: return false; // LATIN CAPITAL LETTER E WITH GRAVE
141: case 0x00C9:
142: return false; // LATIN CAPITAL LETTER E WITH ACUTE
143: case 0x00CA:
144: return false; // LATIN CAPITAL LETTER E WITH CIRCUMFLEX
145: case 0x00CB:
146: return false; // LATIN CAPITAL LETTER E WITH DIAERESIS
147: case 0x00CC:
148: return false; // LATIN CAPITAL LETTER I WITH GRAVE
149: case 0x00CD:
150: return false; // LATIN CAPITAL LETTER I WITH ACUTE
151: case 0x00CE:
152: return false; // LATIN CAPITAL LETTER I WITH CIRCUMFLEX
153: case 0x00CF:
154: return false; // LATIN CAPITAL LETTER I WITH DIAERESIS
155: case 0x00D0:
156: return false; // LATIN CAPITAL LETTER ETH
157: case 0x00D1:
158: return false; // LATIN CAPITAL LETTER N WITH TILDE
159: case 0x00D2:
160: return false; // LATIN CAPITAL LETTER O WITH GRAVE
161: case 0x00D3:
162: return false; // LATIN CAPITAL LETTER O WITH ACUTE
163: case 0x00D4:
164: return false; // LATIN CAPITAL LETTER O WITH CIRCUMFLEX
165: case 0x00D5:
166: return false; // LATIN CAPITAL LETTER O WITH TILDE
167: case 0x00D6:
168: return false; // LATIN CAPITAL LETTER O WITH DIAERESIS
169: case 0x00D7:
170: return false; // MULTIPLICATION SIGN
171: case 0x00D8:
172: return false; // LATIN CAPITAL LETTER O WITH STROKE
173: case 0x00D9:
174: return false; // LATIN CAPITAL LETTER U WITH GRAVE
175: case 0x00DA:
176: return false; // LATIN CAPITAL LETTER U WITH ACUTE
177: case 0x00DB:
178: return false; // LATIN CAPITAL LETTER U WITH CIRCUMFLEX
179: case 0x00DC:
180: return false; // LATIN CAPITAL LETTER U WITH DIAERESIS
181: case 0x00DD:
182: return false; // LATIN CAPITAL LETTER Y WITH ACUTE
183: case 0x00DE:
184: return false; // LATIN CAPITAL LETTER THORN
185: case 0x00DF:
186: return false; // LATIN SMALL LETTER SHARP S
187: case 0x00E0:
188: return false; // LATIN SMALL LETTER A WITH GRAVE
189: case 0x00E1:
190: return false; // LATIN SMALL LETTER A WITH ACUTE
191: case 0x00E2:
192: return false; // LATIN SMALL LETTER A WITH CIRCUMFLEX
193: case 0x00E3:
194: return false; // LATIN SMALL LETTER A WITH TILDE
195: case 0x00E4:
196: return false; // LATIN SMALL LETTER A WITH DIAERESIS
197: case 0x00E5:
198: return false; // LATIN SMALL LETTER A WITH RING ABOVE
199: case 0x00E6:
200: return false; // LATIN SMALL LETTER AE
201: case 0x00E7:
202: return false; // LATIN SMALL LETTER C WITH CEDILLA
203: case 0x00E8:
204: return false; // LATIN SMALL LETTER E WITH GRAVE
205: case 0x00E9:
206: return false; // LATIN SMALL LETTER E WITH ACUTE
207: case 0x00EA:
208: return false; // LATIN SMALL LETTER E WITH CIRCUMFLEX
209: case 0x00EB:
210: return false; // LATIN SMALL LETTER E WITH DIAERESIS
211: case 0x00EC:
212: return false; // LATIN SMALL LETTER I WITH GRAVE
213: case 0x00ED:
214: return false; // LATIN SMALL LETTER I WITH ACUTE
215: case 0x00EE:
216: return false; // LATIN SMALL LETTER I WITH CIRCUMFLEX
217: case 0x00EF:
218: return false; // LATIN SMALL LETTER I WITH DIAERESIS
219: case 0x00F0:
220: return false; // LATIN SMALL LETTER ETH
221: case 0x00F1:
222: return false; // LATIN SMALL LETTER N WITH TILDE
223: case 0x00F2:
224: return false; // LATIN SMALL LETTER O WITH GRAVE
225: case 0x00F3:
226: return false; // LATIN SMALL LETTER O WITH ACUTE
227: case 0x00F4:
228: return false; // LATIN SMALL LETTER O WITH CIRCUMFLEX
229: case 0x00F5:
230: return false; // LATIN SMALL LETTER O WITH TILDE
231: case 0x00F6:
232: return false; // LATIN SMALL LETTER O WITH DIAERESIS
233: case 0x00F7:
234: return false; // DIVISION SIGN
235: case 0x00F8:
236: return false; // LATIN SMALL LETTER O WITH STROKE
237: case 0x00F9:
238: return false; // LATIN SMALL LETTER U WITH GRAVE
239: case 0x00FA:
240: return false; // LATIN SMALL LETTER U WITH ACUTE
241: case 0x00FB:
242: return false; // LATIN SMALL LETTER U WITH CIRCUMFLEX
243: case 0x00FC:
244: return false; // LATIN SMALL LETTER U WITH DIAERESIS
245: case 0x00FD:
246: return false; // LATIN SMALL LETTER Y WITH ACUTE
247: case 0x00FE:
248: return false; // LATIN SMALL LETTER THORN
249: case 0x00FF:
250: return false; // LATIN SMALL LETTER Y WITH DIAERESIS
251: }
252: switch (c) { // uncommon French letters
253: case 0x0152:
254: return false; // LATIN CAPITAL LIGATURE OE
255: case 0x0153:
256: return false; // LATIN SMALL LIGATURE OE
257: case 0x0154:
258: return true; // place holder to enable table lookup
259: case 0x0155:
260: return true; // place holder to enable table lookup
261: case 0x0156:
262: return true; // place holder to enable table lookup
263: case 0x0157:
264: return true; // place holder to enable table lookup
265: case 0x0158:
266: return true; // place holder to enable table lookup
267: case 0x0159:
268: return true; // place holder to enable table lookup
269: case 0x015A:
270: return true; // place holder to enable table lookup
271: case 0x015B:
272: return true; // place holder to enable table lookup
273: case 0x015C:
274: return true; // place holder to enable table lookup
275: case 0x015D:
276: return true; // place holder to enable table lookup
277: case 0x015E:
278: return true; // place holder to enable table lookup
279: case 0x015F:
280: return true; // place holder to enable table lookup
281: case 0x0160:
282: return false; // LATIN CAPITAL LETTER S WITH CARON
283: case 0x0161:
284: return false; // LATIN SMALL LETTER S WITH CARON
285: case 0x0162:
286: return true; // place holder to enable table lookup
287: case 0x0163:
288: return true; // place holder to enable table lookup
289: case 0x0164:
290: return true; // place holder to enable table lookup
291: case 0x0165:
292: return true; // place holder to enable table lookup
293: case 0x0166:
294: return true; // place holder to enable table lookup
295: case 0x0167:
296: return true; // place holder to enable table lookup
297: case 0x0168:
298: return true; // place holder to enable table lookup
299: case 0x0169:
300: return true; // place holder to enable table lookup
301: case 0x016A:
302: return true; // place holder to enable table lookup
303: case 0x016B:
304: return true; // place holder to enable table lookup
305: case 0x016C:
306: return true; // place holder to enable table lookup
307: case 0x016D:
308: return true; // place holder to enable table lookup
309: case 0x016E:
310: return true; // place holder to enable table lookup
311: case 0x016F:
312: return true; // place holder to enable table lookup
313: case 0x0170:
314: return true; // place holder to enable table lookup
315: case 0x0171:
316: return true; // place holder to enable table lookup
317: case 0x0172:
318: return true; // place holder to enable table lookup
319: case 0x0173:
320: return true; // place holder to enable table lookup
321: case 0x0174:
322: return true; // place holder to enable table lookup
323: case 0x0175:
324: return true; // place holder to enable table lookup
325: case 0x0176:
326: return true; // place holder to enable table lookup
327: case 0x0177:
328: return true; // place holder to enable table lookup
329: case 0x0178:
330: return false; // LATIN CAPITAL LETTER Y WITH DIAERESIS
331: case 0x017D:
332: return false; // LATIN CAPITAL LETTER Z WITH CARON
333: case 0x017E:
334: return false; // LATIN SMALL LETTER Z WITH CARON
335: }
336:
337: return true;
338:
339: }
340:
341: }
|