KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nu > xom > ISOGreekWriter


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 JavaDoc;
25
26 /**
27  * <p>
28  * ISO 8859-7, ASCII plus Greek
29  * </p>
30  *
31  * @author Elliotte Rusty Harold
32  * @version 1.0
33  *
34  */

35 class ISOGreekWriter extends TextWriter {
36
37     ISOGreekWriter(Writer JavaDoc out, String JavaDoc encoding) {
38         super(out, encoding);
39     }
40
41     /**
42      * @see nu.xom.TextWriter#needsEscaping(char)
43      */

44     boolean needsEscaping(char c) {
45         if (c <= 0xA0) return false;
46         switch (c) { // Greek
47
case 0x0384: return false; // GREEK TONOS
48
case 0x0385: return false; // GREEK DIALYTIKA TONOS
49
case 0x0386: return false; // GREEK CAPITAL LETTER ALPHA WITH TONOS
50
case 0x0387: return true; // place holder to enable table lookup
51
case 0x0388: return false; // GREEK CAPITAL LETTER EPSILON WITH TONOS
52
case 0x0389: return false; // GREEK CAPITAL LETTER ETA WITH TONOS
53
case 0x038A: return false; // GREEK CAPITAL LETTER IOTA WITH TONOS
54
case 0x038B: return true; // place holder to enable table lookup
55
case 0x038C: return false; // GREEK CAPITAL LETTER OMICRON WITH TONOS
56
case 0x038D: return true; // place holder to enable table lookup
57
case 0x038E: return false; // GREEK CAPITAL LETTER UPSILON WITH TONOS
58
case 0x038F: return false; // GREEK CAPITAL LETTER OMEGA WITH TONOS
59
case 0x0390: return false; // GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS
60
case 0x0391: return false; // GREEK CAPITAL LETTER ALPHA
61
case 0x0392: return false; // GREEK CAPITAL LETTER BETA
62
case 0x0393: return false; // GREEK CAPITAL LETTER GAMMA
63
case 0x0394: return false; // GREEK CAPITAL LETTER DELTA
64
case 0x0395: return false; // GREEK CAPITAL LETTER EPSILON
65
case 0x0396: return false; // GREEK CAPITAL LETTER ZETA
66
case 0x0397: return false; // GREEK CAPITAL LETTER ETA
67
case 0x0398: return false; // GREEK CAPITAL LETTER THETA
68
case 0x0399: return false; // GREEK CAPITAL LETTER IOTA
69
case 0x039A: return false; // GREEK CAPITAL LETTER KAPPA
70
case 0x039B: return false; // GREEK CAPITAL LETTER LAMDA
71
case 0x039C: return false; // GREEK CAPITAL LETTER MU
72
case 0x039D: return false; // GREEK CAPITAL LETTER NU
73
case 0x039E: return false; // GREEK CAPITAL LETTER XI
74
case 0x039F: return false; // GREEK CAPITAL LETTER OMICRON
75
case 0x03A0: return false; // GREEK CAPITAL LETTER PI
76
case 0x03A1: return false; // GREEK CAPITAL LETTER RHO
77
case 0x03A2: return true; // place holder to enable table lookup
78
case 0x03A3: return false; // GREEK CAPITAL LETTER SIGMA
79
case 0x03A4: return false; // GREEK CAPITAL LETTER TAU
80
case 0x03A5: return false; // GREEK CAPITAL LETTER UPSILON
81
case 0x03A6: return false; // GREEK CAPITAL LETTER PHI
82
case 0x03A7: return false; // GREEK CAPITAL LETTER CHI
83
case 0x03A8: return false; // GREEK CAPITAL LETTER PSI
84
case 0x03A9: return false; // GREEK CAPITAL LETTER OMEGA
85
case 0x03AA: return false; // GREEK CAPITAL LETTER IOTA WITH DIALYTIKA
86
case 0x03AB: return false; // GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA
87
case 0x03AC: return false; // GREEK SMALL LETTER ALPHA WITH TONOS
88
case 0x03AD: return false; // GREEK SMALL LETTER EPSILON WITH TONOS
89
case 0x03AE: return false; // GREEK SMALL LETTER ETA WITH TONOS
90
case 0x03AF: return false; // GREEK SMALL LETTER IOTA WITH TONOS
91
case 0x03B0: return false; // GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS
92
case 0x03B1: return false; // GREEK SMALL LETTER ALPHA
93
case 0x03B2: return false; // GREEK SMALL LETTER BETA
94
case 0x03B3: return false; // GREEK SMALL LETTER GAMMA
95
case 0x03B4: return false; // GREEK SMALL LETTER DELTA
96
case 0x03B5: return false; // GREEK SMALL LETTER EPSILON
97
case 0x03B6: return false; // GREEK SMALL LETTER ZETA
98
case 0x03B7: return false; // GREEK SMALL LETTER ETA
99
case 0x03B8: return false; // GREEK SMALL LETTER THETA
100
case 0x03B9: return false; // GREEK SMALL LETTER IOTA
101
case 0x03BA: return false; // GREEK SMALL LETTER KAPPA
102
case 0x03BB: return false; // GREEK SMALL LETTER LAMDA
103
case 0x03BC: return false; // GREEK SMALL LETTER MU
104
case 0x03BD: return false; // GREEK SMALL LETTER NU
105
case 0x03BE: return false; // GREEK SMALL LETTER XI
106
case 0x03BF: return false; // GREEK SMALL LETTER OMICRON
107
case 0x03C0: return false; // GREEK SMALL LETTER PI
108
case 0x03C1: return false; // GREEK SMALL LETTER RHO
109
case 0x03C2: return false; // GREEK SMALL LETTER FINAL SIGMA
110
case 0x03C3: return false; // GREEK SMALL LETTER SIGMA
111
case 0x03C4: return false; // GREEK SMALL LETTER TAU
112
case 0x03C5: return false; // GREEK SMALL LETTER UPSILON
113
case 0x03C6: return false; // GREEK SMALL LETTER PHI
114
case 0x03C7: return false; // GREEK SMALL LETTER CHI
115
case 0x03C8: return false; // GREEK SMALL LETTER PSI
116
case 0x03C9: return false; // GREEK SMALL LETTER OMEGA
117
case 0x03CA: return false; // GREEK SMALL LETTER IOTA WITH DIALYTIKA
118
case 0x03CB: return false; // GREEK SMALL LETTER UPSILON WITH DIALYTIKA
119
case 0x03CC: return false; // GREEK SMALL LETTER OMICRON WITH TONOS
120
case 0x03CD: return false; // GREEK SMALL LETTER UPSILON WITH TONOS
121
case 0x03CE: return false; // GREEK SMALL LETTER OMEGA WITH TONOS
122
}
123         switch (c) { // overlap with Latin-1
124
case 0x00A3: return false; // POUND SIGN
125
case 0x00A4: return true; // place holder to enable table lookup
126
case 0x00A5: return true; // place holder to enable table lookup
127
case 0x00A6: return false; // BROKEN BAR
128
case 0x00A7: return false; // SECTION SIGN
129
case 0x00A8: return false; // DIAERESIS
130
case 0x00A9: return false; // COPYRIGHT SIGN
131
case 0x00AA: return true; // place holder to enable table lookup
132
case 0x00AB: return false; // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
133
case 0x00AC: return false; // NOT SIGN
134
case 0x00AD: return false; // SOFT HYPHEN
135
case 0x00AE: return true; // place holder to enable table lookup
136
case 0x00AF: return true; // place holder to enable table lookup
137
case 0x00B0: return false; // DEGREE SIGN
138
case 0x00B1: return false; // PLUS-MINUS SIGN
139
case 0x00B2: return false; // SUPERSCRIPT TWO
140
case 0x00B3: return false; // SUPERSCRIPT THREE
141
case 0x00B4: return true; // place holder to enable table lookup
142
case 0x00B5: return true; // place holder to enable table lookup
143
case 0x00B6: return true; // place holder to enable table lookup
144
case 0x00B7: return false; // MIDDLE DOT
145
case 0x00B8: return true; // place holder to enable table lookup
146
case 0x00B9: return true; // place holder to enable table lookup
147
case 0x00BA: return true; // place holder to enable table lookup
148
case 0x00BB: return false; // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
149
case 0x00BC: return true; // place holder to enable table lookup
150
case 0x00BD: return false; // VULGAR FRACTION ONE HALF
151
}
152         switch (c) { // assorted characters
153
case 0x2015: return false; // HORIZONTAL BAR
154
// A bug in Java 1.4 and 1.3 prevents a LEFT and RIGHT
155
// SINGLE QUOTATION MARKs
156
// from being correctly output
157
// as the actual character in this encoding
158
// even though it does exist in the
159
// ISO-8859-7 character set.
160
// case 0x2018: return false; // LEFT SINGLE QUOTATION MARK
161
// case 0x2019: return false; // RIGHT SINGLE QUOTATION MARK
162
}
163         return true;
164     }
165
166 }
Popular Tags