aboutsummaryrefslogtreecommitdiffstats
path: root/doc/api-documentation/html/utf8greekaccents_8cpp-source.html
blob: 578e0baaf2e668f5e0975cd260497634c66261e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>utf8greekaccents.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.2.15 -->
<center>
<a class="qindex" href="index.html">Main Page</a> &nbsp; <a class="qindex" href="namespaces.html">Namespace List</a> &nbsp; <a class="qindex" href="hierarchy.html">Class Hierarchy</a> &nbsp; <a class="qindex" href="classes.html">Alphabetical List</a> &nbsp; <a class="qindex" href="annotated.html">Compound List</a> &nbsp; <a class="qindex" href="files.html">File List</a> &nbsp; <a class="qindex" href="functions.html">Compound Members</a> &nbsp; </center>
<hr><h1>utf8greekaccents.cpp</h1><div class="fragment"><pre>00001 <font class="comment">/******************************************************************************</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * UTF8GreekAccents - SWFilter decendant to remove UTF-8 Greek accents</font>
00004 <font class="comment"> *</font>
00005 <font class="comment"> */</font>
00006 
00007 
00008 <font class="preprocessor">#include &lt;stdlib.h&gt;</font>
00009 <font class="preprocessor">#include &lt;stdio.h&gt;</font>
00010 <font class="preprocessor">#include &lt;utf8greekaccents.h&gt;</font>
00011 
00012 
00013 <font class="keyword">const</font> <font class="keywordtype">char</font> UTF8GreekAccents::on[] = <font class="stringliteral">"On"</font>;
00014 <font class="keyword">const</font> <font class="keywordtype">char</font> UTF8GreekAccents::off[] = <font class="stringliteral">"Off"</font>;
00015 <font class="keyword">const</font> <font class="keywordtype">char</font> UTF8GreekAccents::optName[] = <font class="stringliteral">"Greek Accents"</font>;
00016 <font class="keyword">const</font> <font class="keywordtype">char</font> UTF8GreekAccents::optTip[] = <font class="stringliteral">"Toggles Greek Accents"</font>;
00017 
00018 UTF8GreekAccents::UTF8GreekAccents() {
00019         option = <font class="keyword">true</font>;
00020         options.push_back(on);
00021         options.push_back(off);
00022 }
00023 
00024 UTF8GreekAccents::~UTF8GreekAccents(){};
00025 
00026 <font class="keywordtype">void</font> UTF8GreekAccents::setOptionValue(<font class="keyword">const</font> <font class="keywordtype">char</font> *ival)
00027 {
00028         option = (!stricmp(ival, on));
00029 }
00030 
00031 <font class="keyword">const</font> <font class="keywordtype">char</font> *UTF8GreekAccents::getOptionValue()
00032 {
00033         <font class="keywordflow">return</font> (option) ? on:off;
00034 }
00035 
00036 <font class="keywordtype">char</font> UTF8GreekAccents::ProcessText(<font class="keywordtype">char</font> *text, <font class="keywordtype">int</font> maxlen, <font class="keyword">const</font> <a class="code" href="class_s_w_key.html">SWKey</a> *key, <font class="keyword">const</font> <a class="code" href="class_s_w_module.html">SWModule</a> *module)
00037 {
00038         <font class="keywordflow">if</font> (!option) {
00039     <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *to, *from;
00040 
00041         to = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*)text;
00042         <font class="keywordflow">for</font> (from = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>*)text; *from; from++) {
00043           <font class="comment">//first just remove combining characters</font>
00044           <font class="keywordflow">if</font> (*from == 0xE2 &amp;&amp; *(from + 1) == 0x80 &amp;&amp; *(from + 2) == 0x99)
00045             from += 2;
00046           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xCC &amp;&amp; *(from + 1)) {
00047             <font class="keywordflow">if</font> (*(from + 1) == 0x80 || *(from + 1) == 0x81 || *(from + 1) == 0x82 || *(from + 1) == 0x88 || *(from + 1) == 0x93 || *(from + 1) == 0x94)
00048               from++;
00049           }
00050           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xCD &amp;&amp; *(from + 1) == 0xBA)
00051             from++;
00052           <font class="comment">//now converted pre-composed characters to their alphabetic bases, discarding the accents</font>
00053 
00054           <font class="comment">//Greek</font>
00055           <font class="comment">//capital alpha</font>
00056           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x86)) {
00057             *to++ = 0xCE;
00058             *to++ = 0x91;
00059             from++;
00060           }
00061           <font class="comment">//capital epsilon</font>
00062           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x88)) {
00063             *to++ = 0xCE;
00064             *to++ = 0x95;
00065             from++;
00066           }
00067           <font class="comment">//capital eta</font>
00068           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x89)) {
00069             *to++ = 0xCE;
00070             *to++ = 0x97;
00071             from++;
00072           }
00073           <font class="comment">//capital iota</font>
00074           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; (*(from + 1) == 0x8A || *(from + 1) == 0xAA))) {
00075             *to++ = 0xCE;
00076             *to++ = 0x99;
00077             from++;
00078           }
00079           <font class="comment">//capital omicron</font>
00080           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x8C)) {
00081             *to++ = 0xCE;
00082             *to++ = 0x9F;
00083             from++;
00084           }
00085           <font class="comment">//capital upsilon</font>
00086           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; (*(from + 1) == 0x8E || *(from + 1) == 0xAB))) {
00087             *to++ = 0xCE;
00088             *to++ = 0xA5;
00089             from++;
00090           }
00091           <font class="comment">//capital omega</font>
00092           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x8F)) {
00093             *to++ = 0xCE;
00094             *to++ = 0xA9;
00095             from++;
00096           }
00097 
00098           <font class="comment">//alpha</font>
00099           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0xAC)) {
00100             *to++ = 0xCE;
00101             *to++ = 0xB1;
00102             from++;
00103           }
00104           <font class="comment">//epsilon</font>
00105           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0xAD)) {
00106             *to++ = 0xCE;
00107             *to++ = 0xB5;
00108             from++;
00109           }
00110           <font class="comment">//eta</font>
00111           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0xAE)) {
00112             *to++ = 0xCE;
00113             *to++ = 0xB7;
00114             from++;
00115           }
00116           <font class="comment">//iota</font>
00117           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0xAF) || (*from == 0xCF &amp;&amp; *(from + 1) == 0x8A)) {
00118             *to++ = 0xCE;
00119             *to++ = 0xB9;
00120             from++;
00121           }
00122           <font class="comment">//omicron</font>
00123           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCF &amp;&amp; *(from + 1) == 0x8C)) {
00124             *to++ = 0xCE;
00125             *to++ = 0xBF;
00126             from++;
00127           }
00128           <font class="comment">//upsilon</font>
00129           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCE &amp;&amp; *(from + 1) == 0x88) || (*from == 0xCF &amp;&amp; (*(from + 1) == 0x8B || *(from + 1) == 0x8D))) {
00130             *to++ = 0xCF;
00131             *to++ = 0x85;
00132             from++;
00133           }
00134           <font class="comment">//omega</font>
00135           <font class="keywordflow">else</font> <font class="keywordflow">if</font> ((*from == 0xCF &amp;&amp; *(from + 1) == 0x8E)) {
00136             *to++ = 0xCF;
00137             *to++ = 0x89;
00138             from++;
00139           }
00140 
00141           <font class="comment">//Extended Greek</font>
00142           <font class="comment">//capital alpha</font>
00143           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC || *(from + 1) == 0xBE) &amp;&amp; *(from + 2) &gt;= 0x88 &amp;&amp; *(from + 2) &lt;= 0x8F) || (*(from + 1) == 0xBE &amp;&amp; *(from + 2) &gt;= 0xB8 &amp;&amp; *(from + 2) &lt;= 0xBC)) {
00144             *to++ = 0xCE;
00145             *to++ = 0x91;
00146             from+=2;
00147           }
00148           <font class="comment">//capital epsilon</font>
00149           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0x98 &amp;&amp; *(from + 2) &lt;= 0x9D) || (*(from + 1) == 0xBF &amp;&amp; (*(from + 2) == 0x88 || *(from + 2) == 0x89)))) {
00150             *to++ = 0xCE;
00151             *to++ = 0x95;
00152             from+=2;
00153           }
00154           <font class="comment">//capital eta</font>
00155           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0xA8 &amp;&amp; *(from + 2) &lt;= 0xAF) || (*(from + 1) == 0xBE &amp;&amp; *(from + 2) &gt;= 0x98 &amp;&amp; *(from + 2) &lt;= 0x9F) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0x8A &amp;&amp; *(from + 2) &lt;= 0x8C))) {
00156             *to++ = 0xCE;
00157             *to++ = 0x97;
00158             from+=2;
00159           }
00160           <font class="comment">//capital iota</font>
00161           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0xB8 &amp;&amp; *(from + 2) &lt;= 0xBF) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0x98 &amp;&amp; *(from + 2) &lt;= 0x9B))) {
00162             *to++ = 0xCE;
00163             *to++ = 0x99;
00164             from+=2;
00165           }
00166           <font class="comment">//capital omicron</font>
00167           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBD &amp;&amp; *(from + 2) &gt;= 0x88 &amp;&amp; *(from + 2) &lt;= 0x8D) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) == 0xB8 || *(from + 2) == 0xB9))) {
00168             *to++ = 0xCE;
00169             *to++ = 0x9F;
00170             from+=2;
00171           }
00172           <font class="comment">//capital upsilon</font>
00173           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBD &amp;&amp; *(from + 2) &gt;= 0x99 &amp;&amp; *(from + 2) &lt;= 0x9F) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0xA8 &amp;&amp; *(from + 2) &lt;= 0xAB))) {
00174             *to++ = 0xCE;
00175             *to++ = 0xA5;
00176             from+=2;
00177           }
00178           <font class="comment">//capital omega</font>
00179           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; (((*(from + 1) == 0xBD || *(from + 1) == 0xBE) &amp;&amp; *(from + 2) &gt;= 0xA8 &amp;&amp; *(from + 2) &lt;= 0xAF) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0xBA &amp;&amp; *(from + 2) &lt;= 0xBC))) {
00180             *to++ = 0xCE;
00181             *to++ = 0xA9;
00182             from+=2;
00183           }
00184           <font class="comment">//capital rho</font>
00185           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; *(from + 1) == 0xBF &amp;&amp; *(from + 2) == 0xAC) {
00186             *to++ = 0xCE;
00187             *to++ = 0xA1;
00188             from+=2;
00189           }
00190 
00191           <font class="comment">//alpha</font>
00192           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC || *(from + 1) == 0xBE) &amp;&amp; *(from + 2) &gt;= 0x80 &amp;&amp; *(from + 2) &lt;= 0x87) || (*(from + 1) == 0xBD &amp;&amp; (*(from + 2) == 0xB0 || *(from + 2) == 0xB1)) || (*(from + 1) == 0xBE &amp;&amp; *(from + 2) &gt;= 0xB0 &amp;&amp; *(from + 2) &lt;= 0xB7)) {
00193             *to++ = 0xCE;
00194             *to++ = 0xB1;
00195             from+=2;
00196           }
00197           <font class="comment">//epsilon</font>
00198           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0x90 &amp;&amp; *(from + 2) &lt;= 0x95) || (*(from + 1) == 0xBD &amp;&amp; (*(from + 2) == 0xB2 || *(from + 2) == 0xB3)))) {
00199             *to++ = 0xCE;
00200             *to++ = 0xB5;
00201             from+=2;
00202           }
00203           <font class="comment">//eta</font>
00204           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBE &amp;&amp; *(from + 2) &gt;= 0x90 &amp;&amp; *(from + 2) &lt;= 0x97) || (*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0xA0 &amp;&amp; *(from + 2) &lt;= 0xA7) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0x82 &amp;&amp; *(from + 2) &lt;= 0x87) || (*(from + 1) == 0xBD &amp;&amp; (*(from + 2) == 0xB4 || *(from + 2) == 0xB5)))) {
00205             *to++ = 0xCE;
00206             *to++ = 0xB7;
00207             from+=2;
00208           }
00209           <font class="comment">//iota</font>
00210           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBC &amp;&amp; *(from + 2) &gt;= 0xB0 &amp;&amp; *(from + 2) &lt;= 0xB7) || (*(from + 1) == 0xBD &amp;&amp; (*(from + 2) == 0xB6 || *(from + 2) == 0xB7)) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0x90 &amp;&amp; *(from + 2) &lt;= 0x97))) {
00211             *to++ = 0xCE;
00212             *to++ = 0xB9;
00213             from+=2;
00214           }
00215           <font class="comment">//omicron</font>
00216           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; (*(from + 1) == 0xBD &amp;&amp; ((*(from + 2) &gt;= 0x80 &amp;&amp; *(from + 2) &lt;= 0x85) || (*(from + 2) == 0xB8 || *(from + 2) == 0xB9)))) {
00217             *to++ = 0xCE;
00218             *to++ = 0xBF;
00219             from+=2;
00220           }
00221           <font class="comment">//upsilon</font>
00222           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBD &amp;&amp; ((*(from + 2) &gt;= 0x90 &amp;&amp; *(from + 2) &lt;= 0x97) || *(from + 2) == 0xBA || *(from + 2) == 0xBB)) || (*(from + 1) == 0xBF &amp;&amp; ((*(from + 2) &gt;= 0xA0 &amp;&amp; *(from + 2) &lt;= 0xA3) || *(from + 2) == 0xA6 || *(from + 2) == 0xA7)))) {
00223             *to++ = 0xCF;
00224             *to++ = 0x85;
00225             from+=2;
00226           }
00227           <font class="comment">//omega</font>
00228           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; ((*(from + 1) == 0xBD &amp;&amp; ((*(from + 2) &gt;= 0xA0 &amp;&amp; *(from + 2) &lt;= 0xA7) || (*(from + 2) == 0xBC || *(from + 2) == 0xBD))) || (*(from + 1) == 0xBE &amp;&amp; (*(from + 2) &gt;= 0xA0 &amp;&amp; *(from + 2) &lt;= 0xA7)) || (*(from + 1) == 0xBF &amp;&amp; *(from + 2) &gt;= 0xB2 &amp;&amp; *(from + 2) &lt;= 0xB7))) {
00229             *to++ = 0xCF;
00230             *to++ = 0x89;
00231             from+=2;
00232           }
00233           <font class="comment">//rho</font>
00234           <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xE1 &amp;&amp; *(from + 1) == 0xBF &amp;&amp; (*(from + 2) == 0xA4 &amp;&amp; *(from + 2) == 0xA5)) {
00235             *to++ = 0xCF;
00236             *to++ = 0x81;
00237             from+=2;
00238           }
00239           <font class="keywordflow">else</font>
00240             *to++ = *from;
00241         }
00242         *to++ = 0;
00243         *to = 0;
00244      }
00245         <font class="keywordflow">return</font> 0;
00246 }
00247 
00248 
00249 
00250 
00251 
00252 
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 
width=110 height=53></a>1.2.15 </small></address>
</body>
</html>