blob: 578e0baaf2e668f5e0975cd260497634c66261e0 (
plain) (
tree)
|
|
<!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> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </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 <stdlib.h></font>
00009 <font class="preprocessor">#include <stdio.h></font>
00010 <font class="preprocessor">#include <utf8greekaccents.h></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 && *(from + 1) == 0x80 && *(from + 2) == 0x99)
00045 from += 2;
00046 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*from == 0xCC && *(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 && *(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 && *(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 && *(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 && *(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 && (*(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 && *(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 && (*(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 && *(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 && *(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 && *(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 && *(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 && *(from + 1) == 0xAF) || (*from == 0xCF && *(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 && *(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 && *(from + 1) == 0x88) || (*from == 0xCF && (*(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 && *(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 && ((*(from + 1) == 0xBC || *(from + 1) == 0xBE) && *(from + 2) >= 0x88 && *(from + 2) <= 0x8F) || (*(from + 1) == 0xBE && *(from + 2) >= 0xB8 && *(from + 2) <= 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 && ((*(from + 1) == 0xBC && *(from + 2) >= 0x98 && *(from + 2) <= 0x9D) || (*(from + 1) == 0xBF && (*(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 && ((*(from + 1) == 0xBC && *(from + 2) >= 0xA8 && *(from + 2) <= 0xAF) || (*(from + 1) == 0xBE && *(from + 2) >= 0x98 && *(from + 2) <= 0x9F) || (*(from + 1) == 0xBF && *(from + 2) >= 0x8A && *(from + 2) <= 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 && ((*(from + 1) == 0xBC && *(from + 2) >= 0xB8 && *(from + 2) <= 0xBF) || (*(from + 1) == 0xBF && *(from + 2) >= 0x98 && *(from + 2) <= 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 && ((*(from + 1) == 0xBD && *(from + 2) >= 0x88 && *(from + 2) <= 0x8D) || (*(from + 1) == 0xBF && *(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 && ((*(from + 1) == 0xBD && *(from + 2) >= 0x99 && *(from + 2) <= 0x9F) || (*(from + 1) == 0xBF && *(from + 2) >= 0xA8 && *(from + 2) <= 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 && (((*(from + 1) == 0xBD || *(from + 1) == 0xBE) && *(from + 2) >= 0xA8 && *(from + 2) <= 0xAF) || (*(from + 1) == 0xBF && *(from + 2) >= 0xBA && *(from + 2) <= 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 && *(from + 1) == 0xBF && *(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 && ((*(from + 1) == 0xBC || *(from + 1) == 0xBE) && *(from + 2) >= 0x80 && *(from + 2) <= 0x87) || (*(from + 1) == 0xBD && (*(from + 2) == 0xB0 || *(from + 2) == 0xB1)) || (*(from + 1) == 0xBE && *(from + 2) >= 0xB0 && *(from + 2) <= 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 && ((*(from + 1) == 0xBC && *(from + 2) >= 0x90 && *(from + 2) <= 0x95) || (*(from + 1) == 0xBD && (*(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 && ((*(from + 1) == 0xBE && *(from + 2) >= 0x90 && *(from + 2) <= 0x97) || (*(from + 1) == 0xBC && *(from + 2) >= 0xA0 && *(from + 2) <= 0xA7) || (*(from + 1) == 0xBF && *(from + 2) >= 0x82 && *(from + 2) <= 0x87) || (*(from + 1) == 0xBD && (*(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 && ((*(from + 1) == 0xBC && *(from + 2) >= 0xB0 && *(from + 2) <= 0xB7) || (*(from + 1) == 0xBD && (*(from + 2) == 0xB6 || *(from + 2) == 0xB7)) || (*(from + 1) == 0xBF && *(from + 2) >= 0x90 && *(from + 2) <= 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 && (*(from + 1) == 0xBD && ((*(from + 2) >= 0x80 && *(from + 2) <= 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 && ((*(from + 1) == 0xBD && ((*(from + 2) >= 0x90 && *(from + 2) <= 0x97) || *(from + 2) == 0xBA || *(from + 2) == 0xBB)) || (*(from + 1) == 0xBF && ((*(from + 2) >= 0xA0 && *(from + 2) <= 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 && ((*(from + 1) == 0xBD && ((*(from + 2) >= 0xA0 && *(from + 2) <= 0xA7) || (*(from + 2) == 0xBC || *(from + 2) == 0xBD))) || (*(from + 1) == 0xBE && (*(from + 2) >= 0xA0 && *(from + 2) <= 0xA7)) || (*(from + 1) == 0xBF && *(from + 2) >= 0xB2 && *(from + 2) <= 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 && *(from + 1) == 0xBF && (*(from + 2) == 0xA4 && *(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>
|