<!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>Greek2Greek.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>Greek2Greek.cpp</h1><div class="fragment"><pre>00001 <font class="comment">//*****************************************************************************</font>
00002 <font class="comment">// Author : William Dicks ***</font>
00003 <font class="comment">// Date Created: 10 February 1998 ***</font>
00004 <font class="comment">// Purpose : Implementation for Greek to b-Greek conversion and vice ***</font>
00005 <font class="comment">// : versa. ***</font>
00006 <font class="comment">// File Name : Greek2Greek.cpp ***</font>
00007 <font class="comment">// ***</font>
00008 <font class="comment">// Author info : ---------------------------------------------------------- ***</font>
00009 <font class="comment">// Address : 23 Tieroogpark ***</font>
00010 <font class="comment">// : Hoewe Str ***</font>
00011 <font class="comment">// : Elarduspark X3 ***</font>
00012 <font class="comment">// : 0181 ***</font>
00013 <font class="comment">// : South Africa ***</font>
00014 <font class="comment">// Home Tel: +27 (0)12 345 3166 ***</font>
00015 <font class="comment">// Cell No : +27 (0)82 577 4424 ***</font>
00016 <font class="comment">// e-mail : wd@isis.co.za ***</font>
00017 <font class="comment">// Church WWW : http://www.hatfield.co.za ***</font>
00018 <font class="comment">// ***</font>
00019 <font class="comment">// Bugfix info : ---------------------------------------------------------- ***</font>
00020 <font class="comment">// Bug #1 : Greek Font character 197 converted to b-Greek "6" ***</font>
00021 <font class="comment">// Date Fixed : 23 February 1998 ***</font>
00022 <font class="comment">//*****************************************************************************</font>
00023
00024 <font class="preprocessor">#include <stdio.h></font>
00025 <font class="preprocessor">#include <string.h></font>
00026 <font class="preprocessor">#include <ctype.h></font>
00027
00028 <font class="preprocessor">#include "Greek2Greek.h"</font>
00029 <font class="preprocessor">#include "GreekChars.h"</font>
00030
00031 <font class="comment">//*****************************************************************************</font>
00032 <font class="comment">// Used to convert a string created by using the Greek font supplied with the</font>
00033 <font class="comment">// Sword Project to a string that conforms to the b-Greek discussion list </font>
00034 <font class="comment">// method of transliteration.</font>
00035 <font class="comment">//*****************************************************************************</font>
00036
00037 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Greek2bGreek(
00038 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sResult,
00039 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sGreekText,
00040 <font class="keywordtype">int</font> nMaxResultBuflen)
00041 {
00042 <font class="keywordtype">char</font> error;
00043
00044 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> NoOfChars = ParseGreek(sResult, sGreekText, nMaxResultBuflen);
00045
00046 <font class="keywordflow">if</font> (NoOfChars < strlen((<font class="keywordtype">char</font> *)sGreekText))
00047 error = 1;
00048 <font class="keywordflow">else</font>
00049 error = 0;
00050
00051 <font class="keywordflow">return</font> error;
00052 }
00053
00054 <font class="comment">//*****************************************************************************</font>
00055 <font class="comment">// Used to convert a string created by using the b-Greek method of </font>
00056 <font class="comment">// transliteration to a string that can be converted to a Greek-font readable </font>
00057 <font class="comment">// string.</font>
00058 <font class="comment">//*****************************************************************************</font>
00059
00060 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> bGreek2Greek(
00061 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sResult,
00062 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sGreekText,
00063 <font class="keywordtype">int</font> nMaxResultBuflen)
00064 {
00065 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> error;
00066
00067 <font class="keywordtype">unsigned</font> <font class="keywordtype">int</font> NoOfChars = ParsebGreek(sResult, sGreekText, nMaxResultBuflen);
00068
00069 <font class="keywordflow">if</font> (NoOfChars < strlen((<font class="keywordtype">char</font> *)sGreekText))
00070 error = 1;
00071 <font class="keywordflow">else</font>
00072 error = 0;
00073
00074 <font class="keywordflow">return</font> error;
00075 }
00076
00077 <font class="comment">//*****************************************************************************</font>
00078 <font class="comment">// Parse a Greek font created string and return the b-Greek equivalent</font>
00079 <font class="comment">//*****************************************************************************</font>
00080
00081 <font class="keywordtype">int</font> ParseGreek(
00082 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sResult,
00083 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sGreekText,
00084 <font class="keywordtype">int</font> nMaxResultBuflen)
00085 {
00086 <font class="keywordtype">int</font> characters = 0;
00087 <font class="keywordtype">int</font> index = 0;
00088 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> tmp;
00089 <font class="keywordtype">bool</font> iota; <font class="comment">// true = IOTA subscript; false = No IOTA</font>
00090 <font class="keywordtype">bool</font> breathing; <font class="comment">// true = add breathing; false = no breathing</font>
00091 <font class="keywordtype">bool</font> rough; <font class="comment">// true = rough breathing; false = smooth</font>
00092
00093 <font class="comment">// While text is not equal to NULL pointer</font>
00094
00095 <font class="keywordflow">while</font> (sGreekText[index] && characters < nMaxResultBuflen)
00096 {
00097 iota = breathing = rough = <font class="keyword">false</font>;
00098 tmp = Font2char(sGreekText[index++], iota, breathing, rough);
00099
00100 <font class="keywordflow">if</font> (breathing)
00101 {
00102 <font class="keywordflow">if</font> (rough) <font class="comment">// Rough breathing</font>
00103 {
00104 sResult[characters++] = ROUGH; <font class="comment">// Add rough breathing "h"</font>
00105 sResult[characters++] = tmp; <font class="comment">// Insert char</font>
00106 }
00107 <font class="keywordflow">else</font>
00108 sResult[characters++] = tmp; <font class="comment">// Insert char</font>
00109 }
00110 <font class="keywordflow">else</font>
00111 {
00112 <font class="keywordflow">if</font> (iota) <font class="comment">// IOTA subscript</font>
00113 {
00114 sResult[characters++] = tmp; <font class="comment">// Insert char</font>
00115 sResult[characters++] = IOTA_SUB; <font class="comment">// Add Iota subscript</font>
00116 }
00117 <font class="keywordflow">else</font>
00118 sResult[characters++] = tmp; <font class="comment">// Insert char</font>
00119 }
00120 }
00121 sResult[characters] = 0; <font class="comment">// Terminate the string</font>
00122
00123 <font class="keywordflow">return</font> index;
00124 }
00125
00126 <font class="comment">//*****************************************************************************</font>
00127 <font class="comment">// Parse a b-Greek string and return the Greek font equivalent</font>
00128 <font class="comment">//*****************************************************************************</font>
00129 <font class="keywordtype">int</font> ParsebGreek(
00130 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sResult,
00131 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sGreekText,
00132 <font class="keywordtype">int</font> nMaxResultBuflen)
00133 {
00134 <font class="keywordtype">int</font> characters = 0;
00135 <font class="keywordtype">int</font> index = 0;
00136 <font class="keywordtype">bool</font> iota = <font class="keyword">false</font>; <font class="comment">// true = IOTA subscript; false = No IOTA</font>
00137 <font class="keywordtype">bool</font> breathing = <font class="keyword">false</font>; <font class="comment">// true = add breathing; false = no breathing</font>
00138 <font class="keywordtype">bool</font> rough = <font class="keyword">false</font>; <font class="comment">// true = rough breathing; false = smooth</font>
00139 <font class="keywordtype">bool</font> fSigma = <font class="keyword">false</font>; <font class="comment">// Final sigma flag</font>
00140 <font class="keywordtype">bool</font> nChar = <font class="keyword">true</font>; <font class="comment">// New char flag</font>
00141
00142 <font class="comment">// While text is not equal to NULL pointer</font>
00143
00144 <font class="keywordflow">while</font> (*sGreekText || characters < nMaxResultBuflen)
00145 {
00146 <font class="keywordflow">if</font> (nChar)
00147 {
00148 <font class="keywordflow">if</font> (*sGreekText == (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)ROUGH)
00149 {
00150 rough = <font class="keyword">true</font>;
00151 breathing = <font class="keyword">true</font>;
00152 }
00153 <font class="keywordflow">else</font>
00154 {
00155 rough = <font class="keyword">false</font>;
00156 breathing = <font class="keyword">true</font>;
00157 }
00158
00159 nChar = <font class="keyword">false</font>;
00160 }
00161 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (isPunctSpace(*(sGreekText + 1)))
00162 {
00163 fSigma = <font class="keyword">true</font>;
00164 }
00165 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (*(sGreekText + 1) == (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)IOTA_SUB)
00166 {
00167 iota = <font class="keyword">true</font>;
00168 }
00169
00170 <font class="keywordflow">if</font> (*sGreekText != (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)IOTA_SUB)
00171 {
00172 <font class="keywordflow">if</font> (*sGreekText == (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)<font class="charliteral">' '</font>)
00173 {
00174 nChar = <font class="keyword">true</font>;
00175 }
00176
00177 <font class="keywordflow">if</font> (breathing)
00178 {
00179 <font class="keywordflow">if</font> (rough)
00180 {
00181 <font class="comment">// When we read a rough breather we want to increment the pointer </font>
00182 <font class="comment">// to the right character before char2Font is called.</font>
00183
00184 sResult[index++] =
00185 char2Font(*++sGreekText, fSigma, iota, breathing, rough);
00186
00187 sGreekText++;
00188 characters++;
00189 }
00190 <font class="keywordflow">else</font>
00191 {
00192 sResult[index++] =
00193 char2Font(*sGreekText++, fSigma, iota, breathing, rough);
00194 characters++;
00195 }
00196 }
00197 <font class="keywordflow">else</font>
00198 {
00199 sResult[index++] =
00200 char2Font(*sGreekText++, fSigma, iota, breathing, rough);
00201 characters++;
00202 }
00203 }
00204 <font class="keywordflow">else</font>
00205 {
00206 sGreekText++;
00207 characters++;
00208 }
00209
00210 fSigma = iota = breathing = rough = <font class="keyword">false</font>;
00211 }
00212
00213 sResult[index] = 0; <font class="comment">// Terminate the string</font>
00214
00215 <font class="keywordflow">return</font> characters;
00216 }
00217
00218
00219 <font class="comment">//*****************************************************************************</font>
00220 <font class="comment">// Convert a character to a GREEK font character</font>
00221 <font class="comment">//*****************************************************************************</font>
00222 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> char2Font(
00223 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> letter, <font class="comment">// bGreek letter to convert to Font letter</font>
00224 <font class="keywordtype">bool</font> finalSigma, <font class="comment">// Is it a final SIGMA</font>
00225 <font class="keywordtype">bool</font> iota, <font class="comment">// true = IOTA subscript; false = No IOTA</font>
00226 <font class="keywordtype">bool</font> breathing, <font class="comment">// true = add breathing; false = no breathing</font>
00227 <font class="keywordtype">bool</font> rough) <font class="comment">// true = rough breathing; false = smooth</font>
00228 {
00229 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> charFont = 0;
00230
00231 <font class="keywordflow">switch</font> (letter)
00232 {
00233 <font class="keywordflow">case</font> ALPHA: <font class="comment">// A</font>
00234 <font class="keywordflow">if</font> (breathing)
00235 {
00236 <font class="keywordflow">if</font> (rough)
00237 {
00238 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_ALPHA;
00239 }
00240 <font class="keywordflow">else</font>
00241 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_ALPHA;
00242 }
00243 <font class="keywordflow">else</font>
00244 {
00245 <font class="keywordflow">if</font> (iota)
00246 {
00247 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gIOTA_ALPHA;
00248 }
00249 <font class="keywordflow">else</font>
00250 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gALPHA;
00251 }
00252
00253 <font class="keywordflow">break</font>;
00254
00255 <font class="keywordflow">case</font> BETA: <font class="comment">// B</font>
00256 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gBETA;
00257
00258 <font class="keywordflow">break</font>;
00259
00260 <font class="keywordflow">case</font> CHI: <font class="comment">// C</font>
00261 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gCHI;
00262
00263 <font class="keywordflow">break</font>;
00264
00265 <font class="keywordflow">case</font> DELTA: <font class="comment">// D</font>
00266 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gDELTA;
00267
00268 <font class="keywordflow">break</font>;
00269
00270 <font class="keywordflow">case</font> EPSILON: <font class="comment">// E</font>
00271 <font class="keywordflow">if</font> (breathing)
00272 {
00273 <font class="keywordflow">if</font> (rough)
00274 {
00275 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_EPSILON;
00276 }
00277 <font class="keywordflow">else</font>
00278 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_EPSILON;
00279 }
00280 <font class="keywordflow">else</font>
00281 {
00282 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gEPSILON;
00283 }
00284
00285 <font class="keywordflow">break</font>;
00286
00287 <font class="keywordflow">case</font> PHI: <font class="comment">// F</font>
00288 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gPHI;
00289
00290 <font class="keywordflow">break</font>;
00291
00292 <font class="keywordflow">case</font> GAMMA: <font class="comment">// G</font>
00293 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gGAMMA;
00294
00295 <font class="keywordflow">break</font>;
00296
00297 <font class="keywordflow">case</font> ETA: <font class="comment">// H</font>
00298 <font class="keywordflow">if</font> (breathing)
00299 {
00300 <font class="keywordflow">if</font> (rough)
00301 {
00302 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_ETA;
00303 }
00304 <font class="keywordflow">else</font>
00305 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_ETA;
00306 }
00307 <font class="keywordflow">else</font>
00308 {
00309 <font class="keywordflow">if</font> (iota)
00310 {
00311 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gIOTA_ETA;
00312 }
00313 <font class="keywordflow">else</font>
00314 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gETA;
00315 }
00316
00317 <font class="keywordflow">break</font>;
00318
00319 <font class="keywordflow">case</font> IOTA: <font class="comment">// I</font>
00320 <font class="keywordflow">if</font> (breathing)
00321 {
00322 <font class="keywordflow">if</font> (rough)
00323 {
00324 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_IOTA;
00325 }
00326 <font class="keywordflow">else</font>
00327 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_IOTA;
00328 }
00329 <font class="keywordflow">else</font>
00330 {
00331 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gIOTA;
00332 }
00333
00334 <font class="keywordflow">break</font>;
00335
00336 <font class="keywordflow">case</font> KAPPA: <font class="comment">// K</font>
00337 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gKAPPA;
00338
00339 <font class="keywordflow">break</font>;
00340
00341 <font class="keywordflow">case</font> LAMBDA: <font class="comment">// L</font>
00342 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gLAMBDA;
00343
00344 <font class="keywordflow">break</font>;
00345
00346 <font class="keywordflow">case</font> MU: <font class="comment">// M</font>
00347 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gMU;
00348
00349 <font class="keywordflow">break</font>;
00350
00351 <font class="keywordflow">case</font> NU: <font class="comment">// N</font>
00352 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNU;
00353
00354 <font class="keywordflow">break</font>;
00355
00356 <font class="keywordflow">case</font> OMICRON: <font class="comment">// O</font>
00357 <font class="keywordflow">if</font> (breathing)
00358 {
00359 <font class="keywordflow">if</font> (rough)
00360 {
00361 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_OMICRON;
00362 }
00363 <font class="keywordflow">else</font>
00364 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_OMICRON;
00365 }
00366 <font class="keywordflow">else</font>
00367 {
00368 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gOMICRON;
00369 }
00370
00371 <font class="keywordflow">break</font>;
00372
00373 <font class="keywordflow">case</font> PI: <font class="comment">// P</font>
00374 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gPI;
00375
00376 <font class="keywordflow">break</font>;
00377
00378 <font class="keywordflow">case</font> THETA: <font class="comment">// Q</font>
00379 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gTHETA;
00380
00381 <font class="keywordflow">break</font>;
00382
00383 <font class="keywordflow">case</font> RHO: <font class="comment">// R</font>
00384 <font class="keywordflow">if</font> (breathing)
00385 {
00386 <font class="keywordflow">if</font> (rough)
00387 {
00388 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_RHO;
00389 }
00390 <font class="keywordflow">else</font>
00391 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_RHO;
00392 }
00393 <font class="keywordflow">else</font>
00394 {
00395 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gRHO;
00396 }
00397
00398 <font class="keywordflow">break</font>;
00399
00400 <font class="keywordflow">case</font> SIGMA: <font class="comment">// S</font>
00401 <font class="keywordflow">if</font> (finalSigma)
00402 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gSIGMA_END;
00403 <font class="keywordflow">else</font>
00404 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gSIGMA;
00405
00406 <font class="keywordflow">break</font>;
00407
00408 <font class="keywordflow">case</font> TAU: <font class="comment">// T</font>
00409 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gTAU;
00410
00411 <font class="keywordflow">break</font>;
00412
00413 <font class="keywordflow">case</font> UPSILON: <font class="comment">// U</font>
00414 <font class="keywordflow">if</font> (breathing)
00415 {
00416 <font class="keywordflow">if</font> (rough)
00417 {
00418 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_UPSILON;
00419 }
00420 <font class="keywordflow">else</font>
00421 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_UPSILON;
00422 }
00423 <font class="keywordflow">else</font>
00424 {
00425 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gUPSILON;
00426 }
00427
00428 <font class="keywordflow">break</font>;
00429
00430 <font class="keywordflow">case</font> OMEGA: <font class="comment">// W</font>
00431 <font class="keywordflow">if</font> (breathing)
00432 {
00433 <font class="keywordflow">if</font> (rough)
00434 {
00435 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gROUGH_OMEGA;
00436 }
00437 <font class="keywordflow">else</font>
00438 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gNON_ROUGH_OMEGA;
00439 }
00440 <font class="keywordflow">else</font>
00441 {
00442 <font class="keywordflow">if</font> (iota)
00443 {
00444 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gIOTA_OMEGA;
00445 }
00446 <font class="keywordflow">else</font>
00447 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gOMEGA;
00448 }
00449
00450 <font class="keywordflow">break</font>;
00451
00452 <font class="keywordflow">case</font> XI: <font class="comment">// X</font>
00453 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gXI;
00454
00455 <font class="keywordflow">break</font>;
00456
00457 <font class="keywordflow">case</font> PSI: <font class="comment">// Y</font>
00458 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gPSI;
00459
00460 <font class="keywordflow">break</font>;
00461
00462 <font class="keywordflow">case</font> ZETA: <font class="comment">// Z</font>
00463 charFont = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>)gZETA;
00464
00465 <font class="keywordflow">break</font>;
00466
00467 <font class="keywordflow">default</font>:
00468 <font class="keywordflow">if</font> (ispunct(letter) || isspace(letter))
00469 {
00470 charFont = getGreekPunct(letter);
00471 }
00472
00473 <font class="keywordflow">if</font> (isdigit(letter))
00474 charFont = letter;
00475
00476 <font class="keywordflow">break</font>;
00477 }
00478
00479 <font class="keywordflow">return</font> charFont;
00480 }
00481
00482
00483 <font class="comment">//*****************************************************************************</font>
00484 <font class="comment">// Convert a GREEK font character to a character</font>
00485 <font class="comment">//*****************************************************************************</font>
00486 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Font2char(
00487 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> letter, <font class="comment">// bGreek letter to convert to Font letter</font>
00488 <font class="keywordtype">bool</font> &iota, <font class="comment">// true = IOTA subscript; false = No IOTA</font>
00489 <font class="keywordtype">bool</font> &breathing, <font class="comment">// true = add breathing; false = no breathing</font>
00490 <font class="keywordtype">bool</font> &rough) <font class="comment">// true = rough breathing; false = smooth</font>
00491 {
00492 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> character = 0;
00493
00494 <font class="keywordflow">if</font> (getSpecialChar(letter, letter))
00495 {
00496 <font class="keywordflow">switch</font> (letter)
00497 {
00498 <font class="keywordflow">case</font> gROUGH_ALPHA: <font class="comment">// hA</font>
00499 <font class="keywordflow">case</font> gIOTA_ALPHA: <font class="comment">// Ai</font>
00500 <font class="keywordflow">case</font> gNON_ROUGH_ALPHA: <font class="comment">// hA</font>
00501 character = ALPHA;
00502
00503 <font class="keywordflow">if</font> (letter == gIOTA_ALPHA)
00504 iota = <font class="keyword">true</font>;
00505 <font class="keywordflow">else</font>
00506 iota = <font class="keyword">false</font>;
00507
00508 <font class="keywordflow">if</font> (letter == gROUGH_ALPHA)
00509 {
00510 breathing = <font class="keyword">true</font>;
00511 rough = <font class="keyword">true</font>;
00512 }
00513 <font class="keywordflow">else</font>
00514 {
00515 breathing = <font class="keyword">false</font>;
00516 rough = <font class="keyword">false</font>;
00517 }
00518
00519 <font class="keywordflow">break</font>;
00520
00521 <font class="keywordflow">case</font> gROUGH_EPSILON: <font class="comment">// hE</font>
00522 <font class="keywordflow">case</font> gNON_ROUGH_EPSILON: <font class="comment">// hE</font>
00523 character = EPSILON;
00524 iota = <font class="keyword">false</font>;
00525
00526 <font class="keywordflow">if</font> (letter == gROUGH_EPSILON)
00527 {
00528 breathing = <font class="keyword">true</font>;
00529 rough = <font class="keyword">true</font>;
00530 }
00531 <font class="keywordflow">else</font>
00532 {
00533 breathing = <font class="keyword">false</font>;
00534 rough = <font class="keyword">false</font>;
00535 }
00536
00537 <font class="keywordflow">break</font>;
00538
00539 <font class="keywordflow">case</font> gROUGH_ETA: <font class="comment">// hH</font>
00540 <font class="keywordflow">case</font> gIOTA_ETA: <font class="comment">// Ei</font>
00541 <font class="keywordflow">case</font> gNON_ROUGH_ETA: <font class="comment">// hH</font>
00542 character = ETA;
00543
00544 <font class="keywordflow">if</font> (letter == gIOTA_ETA)
00545 iota = <font class="keyword">true</font>;
00546 <font class="keywordflow">else</font>
00547 iota = <font class="keyword">false</font>;
00548
00549 <font class="keywordflow">if</font> (letter == gROUGH_ETA)
00550 {
00551 breathing = <font class="keyword">true</font>;
00552 rough = <font class="keyword">true</font>;
00553 }
00554 <font class="keywordflow">else</font>
00555 {
00556 breathing = <font class="keyword">false</font>;
00557 rough = <font class="keyword">false</font>;
00558 }
00559
00560 <font class="keywordflow">break</font>;
00561
00562 <font class="keywordflow">case</font> gROUGH_IOTA: <font class="comment">// hH</font>
00563 <font class="keywordflow">case</font> gNON_ROUGH_IOTA: <font class="comment">// hH</font>
00564 character = IOTA;
00565 iota = <font class="keyword">false</font>;
00566
00567 <font class="keywordflow">if</font> (letter == gROUGH_IOTA)
00568 {
00569 breathing = <font class="keyword">true</font>;
00570 rough = <font class="keyword">true</font>;
00571 }
00572 <font class="keywordflow">else</font>
00573 {
00574 breathing = <font class="keyword">false</font>;
00575 rough = <font class="keyword">false</font>;
00576 }
00577
00578 <font class="keywordflow">break</font>;
00579
00580 <font class="keywordflow">case</font> gROUGH_OMICRON: <font class="comment">// hH</font>
00581 <font class="keywordflow">case</font> gNON_ROUGH_OMICRON: <font class="comment">// hH</font>
00582 character = OMICRON;
00583 iota = <font class="keyword">false</font>;
00584
00585 <font class="keywordflow">if</font> (letter == gROUGH_OMICRON)
00586 {
00587 breathing = <font class="keyword">true</font>;
00588 rough = <font class="keyword">true</font>;
00589 }
00590 <font class="keywordflow">else</font>
00591 {
00592 breathing = <font class="keyword">false</font>;
00593 rough = <font class="keyword">false</font>;
00594 }
00595
00596 <font class="keywordflow">break</font>;
00597
00598 <font class="keywordflow">case</font> gROUGH_RHO: <font class="comment">// hR</font>
00599 <font class="keywordflow">case</font> gNON_ROUGH_RHO: <font class="comment">// hR</font>
00600 character = RHO;
00601 iota = <font class="keyword">false</font>;
00602
00603 <font class="keywordflow">if</font> (letter == gROUGH_RHO)
00604 {
00605 breathing = <font class="keyword">true</font>;
00606 rough = <font class="keyword">true</font>;
00607 }
00608 <font class="keywordflow">else</font>
00609 {
00610 breathing = <font class="keyword">false</font>;
00611 rough = <font class="keyword">false</font>;
00612 }
00613
00614 <font class="keywordflow">break</font>;
00615
00616 <font class="keywordflow">case</font> gROUGH_UPSILON: <font class="comment">// hU</font>
00617 <font class="keywordflow">case</font> gNON_ROUGH_UPSILON: <font class="comment">// hU</font>
00618 character = UPSILON;
00619 iota = <font class="keyword">false</font>;
00620
00621 <font class="keywordflow">if</font> (letter == gROUGH_UPSILON)
00622 {
00623 breathing = <font class="keyword">true</font>;
00624 rough = <font class="keyword">true</font>;
00625 }
00626 <font class="keywordflow">else</font>
00627 {
00628 breathing = <font class="keyword">false</font>;
00629 rough = <font class="keyword">false</font>;
00630 }
00631
00632 <font class="keywordflow">break</font>;
00633
00634 <font class="keywordflow">case</font> gROUGH_OMEGA: <font class="comment">// hW</font>
00635 <font class="keywordflow">case</font> gIOTA_OMEGA: <font class="comment">// Wi</font>
00636 <font class="keywordflow">case</font> gNON_ROUGH_OMEGA: <font class="comment">// hW</font>
00637 character = OMEGA;
00638
00639 <font class="keywordflow">if</font> (letter == gIOTA_OMEGA)
00640 iota = <font class="keyword">true</font>;
00641 <font class="keywordflow">else</font>
00642 iota = <font class="keyword">false</font>;
00643
00644 <font class="keywordflow">if</font> (letter == gROUGH_OMEGA)
00645 {
00646 breathing = <font class="keyword">true</font>;
00647 rough = <font class="keyword">true</font>;
00648 }
00649 <font class="keywordflow">else</font>
00650 {
00651 breathing = <font class="keyword">false</font>;
00652 rough = <font class="keyword">false</font>;
00653 }
00654
00655 <font class="keywordflow">break</font>;
00656 }
00657 } <font class="comment">// if (letter > SPECIAL_GREEK)</font>
00658 <font class="keywordflow">else</font>
00659 {
00660 <font class="keywordflow">if</font> (letter == gSIGMA_END)
00661 {
00662 character = SIGMA;
00663 }
00664 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (ispunct(letter) || isspace(letter))
00665 {
00666 character = getbGreekPunct(letter);
00667 }
00668 <font class="keywordflow">else</font> <font class="keywordflow">if</font> (isdigit(letter))
00669 {
00670 character = letter;
00671 }
00672 <font class="keywordflow">else</font>
00673 {
00674 character = letter - 32;
00675 }
00676 }
00677
00678 <font class="keywordflow">return</font> character;
00679 }
00680
00681 <font class="comment">//*****************************************************************************</font>
00682 <font class="comment">// Identify and return a bGreek letter from a special font char</font>
00683 <font class="comment">//*****************************************************************************</font>
00684 <font class="keywordtype">bool</font> getSpecialChar(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Font, <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> &letter)
00685 {
00686 <font class="keywordtype">bool</font> Yes = <font class="keyword">false</font>;
00687 letter = Font;
00688
00689 <font class="keywordflow">if</font> (Font >= 133 && Font <= 144)
00690 {
00691 letter = gIOTA;
00692 Font = gIOTA;
00693 }
00694
00695 <font class="keywordflow">if</font> (Font >= 154 && Font <= 159)
00696 {
00697 letter = gEPSILON;
00698 Font = gEPSILON;
00699 }
00700
00701 <font class="keywordflow">if</font> (Font >= 163 && Font <= 171)
00702 {
00703 letter = gALPHA;
00704 Font = gALPHA;
00705 }
00706
00707 <font class="keywordflow">if</font> (Font >= 172 && Font <= 182)
00708 {
00709 letter = gIOTA_ALPHA;
00710 Font = gIOTA_ALPHA;
00711 Yes = <font class="keyword">true</font>;
00712 }
00713
00714 <font class="keywordflow">if</font> (Font >= 187 && Font <= 195)
00715 {
00716 letter = gETA;
00717 Font = gETA;
00718 }
00719
00720 <font class="keywordflow">if</font> (Font >= 197 && Font <= 207)
00721 {
00722 letter = gIOTA_ETA;
00723 Font = gIOTA_ETA;
00724 Yes = <font class="keyword">true</font>;
00725 }
00726
00727 <font class="keywordflow">if</font> ((Font >= 210 && Font <= 215) || Font == 253)
00728 {
00729 letter = gOMICRON;
00730 Font = gOMICRON;
00731 }
00732
00733 <font class="keywordflow">if</font> (Font >= 218 && Font <= 229)
00734 {
00735 letter = gUPSILON;
00736 Font = gUPSILON;
00737 }
00738
00739 <font class="keywordflow">if</font> (Font >= 232 && Font <= 240)
00740 {
00741 letter = gOMEGA;
00742 Font = gOMEGA;
00743 }
00744
00745 <font class="keywordflow">if</font> (Font >= 241 && Font <= 251)
00746 {
00747 letter = gIOTA_OMEGA;
00748 Font = gIOTA_OMEGA;
00749 Yes = <font class="keyword">true</font>;
00750 }
00751
00752 Yes = SpecialGreek(Font);
00753
00754 <font class="keywordflow">return</font> Yes;
00755 }
00756
00757
00758 <font class="comment">//*****************************************************************************</font>
00759 <font class="comment">// true if the font character is a special character; false it isn't</font>
00760 <font class="comment">//*****************************************************************************</font>
00761
00762 <font class="keywordtype">bool</font> SpecialGreek(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Font)
00763 {
00764 <font class="keywordtype">bool</font> res = <font class="keyword">false</font>;
00765
00766 <font class="keywordflow">switch</font> (Font)
00767 {
00768 <font class="keywordflow">case</font> gROUGH_ALPHA:
00769 <font class="keywordflow">case</font> gROUGH_EPSILON:
00770 <font class="keywordflow">case</font> gROUGH_ETA:
00771 <font class="keywordflow">case</font> gROUGH_IOTA:
00772 <font class="keywordflow">case</font> gROUGH_OMICRON:
00773 <font class="keywordflow">case</font> gROUGH_RHO:
00774 <font class="keywordflow">case</font> gROUGH_UPSILON:
00775 <font class="keywordflow">case</font> gROUGH_OMEGA:
00776 <font class="keywordflow">case</font> gIOTA_ALPHA:
00777 <font class="keywordflow">case</font> gIOTA_ETA:
00778 <font class="keywordflow">case</font> gIOTA_OMEGA:
00779 <font class="keywordflow">case</font> gNON_ROUGH_ALPHA:
00780 <font class="keywordflow">case</font> gNON_ROUGH_EPSILON:
00781 <font class="keywordflow">case</font> gNON_ROUGH_ETA:
00782 <font class="keywordflow">case</font> gNON_ROUGH_IOTA:
00783 <font class="keywordflow">case</font> gNON_ROUGH_OMICRON:
00784 <font class="keywordflow">case</font> gNON_ROUGH_RHO:
00785 <font class="keywordflow">case</font> gNON_ROUGH_UPSILON:
00786 <font class="keywordflow">case</font> gNON_ROUGH_OMEGA:
00787 res = <font class="keyword">true</font>;
00788
00789 <font class="keywordflow">break</font>;
00790 }
00791
00792 <font class="keywordflow">return</font> res;
00793 }
00794
00795
00796 <font class="comment">//*****************************************************************************</font>
00797 <font class="comment">// Return Greek font puntuation from bGreek punstuation</font>
00798 <font class="comment">//*****************************************************************************</font>
00799
00800 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> getGreekPunct(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> bGreek)
00801 {
00802 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Font;
00803
00804 <font class="keywordflow">switch</font> (bGreek)
00805 {
00806 <font class="keywordflow">case</font> COMMA:
00807 Font = gCOMMA;
00808 <font class="keywordflow">break</font>;
00809
00810 <font class="keywordflow">case</font> STOP:
00811 Font = gSTOP;
00812 <font class="keywordflow">break</font>;
00813
00814 <font class="keywordflow">case</font> SEMI_COLON:
00815 Font = gSEMI_COLON;
00816 <font class="keywordflow">break</font>;
00817
00818 <font class="keywordflow">case</font> QUESTION:
00819 Font = gQUESTION;
00820 <font class="keywordflow">break</font>;
00821
00822 <font class="keywordflow">default</font>:
00823 Font = <font class="charliteral">' '</font>;
00824 <font class="keywordflow">break</font>;
00825 }
00826
00827 <font class="keywordflow">return</font> Font;
00828 }
00829
00830
00831 <font class="comment">//*****************************************************************************</font>
00832 <font class="comment">// Return bGreek puntuation from Greek font punstuation</font>
00833 <font class="comment">//*****************************************************************************</font>
00834
00835 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> getbGreekPunct(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> Greek)
00836 {
00837 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> character;
00838
00839 <font class="keywordflow">switch</font> (Greek)
00840 {
00841 <font class="keywordflow">case</font> gCOMMA:
00842 character = COMMA;
00843 <font class="keywordflow">break</font>;
00844
00845 <font class="keywordflow">case</font> gSTOP:
00846 character = STOP;
00847 <font class="keywordflow">break</font>;
00848
00849 <font class="keywordflow">case</font> gSEMI_COLON:
00850 character = SEMI_COLON;
00851 <font class="keywordflow">break</font>;
00852
00853 <font class="keywordflow">case</font> gQUESTION:
00854 character = QUESTION;
00855 <font class="keywordflow">break</font>;
00856
00857 <font class="keywordflow">default</font>:
00858 character = <font class="charliteral">' '</font>;
00859 <font class="keywordflow">break</font>;
00860 }
00861
00862 <font class="keywordflow">return</font> character;
00863 }
00864
00865
00866 <font class="comment">//*****************************************************************************</font>
00867 <font class="comment">// Is the character punctuation or a space: true it is, false it isn't</font>
00868 <font class="comment">//*****************************************************************************</font>
00869
00870 <font class="keywordtype">bool</font> isPunctSpace(<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> c)
00871 {
00872 <font class="keywordflow">return</font> (ispunct(c) || isspace(c) || c == 0) ? <font class="keyword">true</font> : <font class="keyword">false</font>;
00873 }
00874
00875 <font class="preprocessor">#ifdef __TEST</font>
00876 <font class="preprocessor"></font>
00877 <font class="keywordtype">int</font> main()
00878 {
00879 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sGreekText = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *)
00880 <font class="stringliteral">"1„£kwboj qeoà kaˆ kur…ou „hsoà cristoà doàloj ta‹j dèdeka fula‹j ta‹j ™n tÍ diaspor´ ca…rein."</font>;
00881 <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *sResult = <font class="keyword">new</font> <font class="keywordtype">unsigned</font> <font class="keywordtype">char</font>[100];
00882
00883 <font class="keywordtype">char</font> result = Greek2bGreek(
00884 sResult,
00885 sGreekText,
00886 100);
00887
00888 strset((<font class="keywordtype">char</font> *)sResult, 0);
00889 strset((<font class="keywordtype">char</font> *)sGreekText, 0);
00890
00891 sGreekText = (<font class="keywordtype">unsigned</font> <font class="keywordtype">char</font> *)<font class="stringliteral">"18 EIS AFESIN TWN hAMARTWN hUMWN?"</font>;
00892 result = bGreek2Greek(
00893 sResult,
00894 sGreekText,
00895 33);
00896
00897 <font class="comment">//delete[] sGreekText;</font>
00898 <font class="keyword">delete</font>[] sResult;
00899 }
00900
00901 <font class="preprocessor">#endif // __TEST</font>
</pre></div><hr><address align="right"><small>Generated on Thu Jun 20 22:12:59 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>