KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nu > xom > ISOThaiWriter


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  * TIS-620, not quite the same as ISO 8859-11.
29  * TIS-620 does not have the non-breaking space or the C1 controls.
30  * </p>
31  *
32  * @author Elliotte Rusty Harold
33  * @version 1.0
34  *
35  */

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

45     boolean needsEscaping(char c) {
46         
47         if (c < 128) return false;
48         // C1 controls do not appear to be assigned in this character set
49
// Also, according to
50
// http://www.inet.co.th/cyberclub/trin/thairef/tis620-iso10646.html
51
// "Special attention should be paid on codepoint A0. Contrary
52
// to many people's belief that TIS 620 defines codepoint A0
53
// as no-break space (U+00A0), the standard does not assign any
54
// character to this codepoint. Codepoints A0 as well as DB-DE
55
// and FC-FF are not part of the standard. Interpretations of
56
// these unassigned codepoints are implementation specific and
57
// may vary from implementation to implementation. To ensure full
58
// data interchangeability among various applications, it is
59
// suggested that Thai software implementors follows the
60
// TIS 620 standard strictly."
61

62         switch (c) {
63             case 0x0E01: return false; // THAI CHARACTER KO KAI
64
case 0x0E02: return false; // THAI CHARACTER KHO KHAI
65
case 0x0E03: return false; // THAI CHARACTER KHO KHUAT
66
case 0x0E04: return false; // THAI CHARACTER KHO KHWAI
67
case 0x0E05: return false; // THAI CHARACTER KHO KHON
68
case 0x0E06: return false; // THAI CHARACTER KHO RAKHANG
69
case 0x0E07: return false; // THAI CHARACTER NGO NGU
70
case 0x0E08: return false; // THAI CHARACTER CHO CHAN
71
case 0x0E09: return false; // THAI CHARACTER CHO CHING
72
case 0x0E0A: return false; // THAI CHARACTER CHO CHANG
73
case 0x0E0B: return false; // THAI CHARACTER SO SO
74
case 0x0E0C: return false; // THAI CHARACTER CHO CHOE
75
case 0x0E0D: return false; // THAI CHARACTER YO YING
76
case 0x0E0E: return false; // THAI CHARACTER DO CHADA
77
case 0x0E0F: return false; // THAI CHARACTER TO PATAK
78
case 0x0E10: return false; // THAI CHARACTER THO THAN
79
case 0x0E11: return false; // THAI CHARACTER THO NANGMONTHO
80
case 0x0E12: return false; // THAI CHARACTER THO PHUTHAO
81
case 0x0E13: return false; // THAI CHARACTER NO NEN
82
case 0x0E14: return false; // THAI CHARACTER DO DEK
83
case 0x0E15: return false; // THAI CHARACTER TO TAO
84
case 0x0E16: return false; // THAI CHARACTER THO THUNG
85
case 0x0E17: return false; // THAI CHARACTER THO THAHAN
86
case 0x0E18: return false; // THAI CHARACTER THO THONG
87
case 0x0E19: return false; // THAI CHARACTER NO NU
88
case 0x0E1A: return false; // THAI CHARACTER BO BAIMAI
89
case 0x0E1B: return false; // THAI CHARACTER PO PLA
90
case 0x0E1C: return false; // THAI CHARACTER PHO PHUNG
91
case 0x0E1D: return false; // THAI CHARACTER FO FA
92
case 0x0E1E: return false; // THAI CHARACTER PHO PHAN
93
case 0x0E1F: return false; // THAI CHARACTER FO FAN
94
case 0x0E20: return false; // THAI CHARACTER PHO SAMPHAO
95
case 0x0E21: return false; // THAI CHARACTER MO MA
96
case 0x0E22: return false; // THAI CHARACTER YO YAK
97
case 0x0E23: return false; // THAI CHARACTER RO RUA
98
case 0x0E24: return false; // THAI CHARACTER RU
99
case 0x0E25: return false; // THAI CHARACTER LO LING
100
case 0x0E26: return false; // THAI CHARACTER LU
101
case 0x0E27: return false; // THAI CHARACTER WO WAEN
102
case 0x0E28: return false; // THAI CHARACTER SO SALA
103
case 0x0E29: return false; // THAI CHARACTER SO RUSI
104
case 0x0E2A: return false; // THAI CHARACTER SO SUA
105
case 0x0E2B: return false; // THAI CHARACTER HO HIP
106
case 0x0E2C: return false; // THAI CHARACTER LO CHULA
107
case 0x0E2D: return false; // THAI CHARACTER O ANG
108
case 0x0E2E: return false; // THAI CHARACTER HO NOKHUK
109
case 0x0E2F: return false; // THAI CHARACTER PAIYANNOI
110
case 0x0E30: return false; // THAI CHARACTER SARA A
111
case 0x0E31: return false; // THAI CHARACTER MAI HAN-AKAT
112
case 0x0E32: return false; // THAI CHARACTER SARA AA
113
case 0x0E33: return false; // THAI CHARACTER SARA AM
114
case 0x0E34: return false; // THAI CHARACTER SARA I
115
case 0x0E35: return false; // THAI CHARACTER SARA II
116
case 0x0E36: return false; // THAI CHARACTER SARA UE
117
case 0x0E37: return false; // THAI CHARACTER SARA UEE
118
case 0x0E38: return false; // THAI CHARACTER SARA U
119
case 0x0E39: return false; // THAI CHARACTER SARA UU
120
case 0x0E3A: return false; // THAI CHARACTER PHINTHU
121
}
122         // optimize by splitting switch into contiguous blocks per
123
// Chapter 7 of Java Performance Tuning, Jack Shirazi
124
switch (c) {
125             case 0x0E3F: return false; // THAI CURRENCY SYMBOL BAHT
126
case 0x0E40: return false; // THAI CHARACTER SARA E
127
case 0x0E41: return false; // THAI CHARACTER SARA AE
128
case 0x0E42: return false; // THAI CHARACTER SARA O
129
case 0x0E43: return false; // THAI CHARACTER SARA AI MAIMUAN
130
case 0x0E44: return false; // THAI CHARACTER SARA AI MAIMALAI
131
case 0x0E45: return false; // THAI CHARACTER LAKKHANGYAO
132
case 0x0E46: return false; // THAI CHARACTER MAIYAMOK
133
case 0x0E47: return false; // THAI CHARACTER MAITAIKHU
134
case 0x0E48: return false; // THAI CHARACTER MAI EK
135
case 0x0E49: return false; // THAI CHARACTER MAI THO
136
case 0x0E4A: return false; // THAI CHARACTER MAI TRI
137
case 0x0E4B: return false; // THAI CHARACTER MAI CHATTAWA
138
case 0x0E4C: return false; // THAI CHARACTER THANTHAKHAT
139
case 0x0E4D: return false; // THAI CHARACTER NIKHAHIT
140
case 0x0E4E: return false; // THAI CHARACTER YAMAKKAN
141
case 0x0E4F: return false; // THAI CHARACTER FONGMAN
142
case 0x0E50: return false; // THAI DIGIT ZERO
143
case 0x0E51: return false; // THAI DIGIT ONE
144
case 0x0E52: return false; // THAI DIGIT TWO
145
case 0x0E53: return false; // THAI DIGIT THREE
146
case 0x0E54: return false; // THAI DIGIT FOUR
147
case 0x0E55: return false; // THAI DIGIT FIVE
148
case 0x0E56: return false; // THAI DIGIT SIX
149
case 0x0E57: return false; // THAI DIGIT SEVEN
150
case 0x0E58: return false; // THAI DIGIT EIGHT
151
case 0x0E59: return false; // THAI DIGIT NINE
152
case 0x0E5A: return false; // THAI CHARACTER ANGKHANKHU
153
case 0x0E5B: return false; // THAI CHARACTER KHOMUT
154
}
155         
156         return true;
157         
158     }
159
160 }
Popular Tags