Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

utf8cantillation.cpp

00001 /******************************************************************************
00002  *
00003  * UTF8Cantillation - SWFilter decendant to remove UTF-8 Hebrew cantillation
00004  *
00005  */
00006 
00007 
00008 #include <stdlib.h>
00009 #include <stdio.h>
00010 #include <utf8cantillation.h>
00011 
00012 
00013 const char UTF8Cantillation::on[] = "On";
00014 const char UTF8Cantillation::off[] = "Off";
00015 const char UTF8Cantillation::optName[] = "Hebrew Cantillation";
00016 const char UTF8Cantillation::optTip[] = "Toggles Hebrew Cantillation Marks";
00017 
00018 UTF8Cantillation::UTF8Cantillation() {
00019         option = false;
00020         options.push_back(on);
00021         options.push_back(off);
00022 }
00023 
00024 UTF8Cantillation::~UTF8Cantillation(){};
00025 
00026 void UTF8Cantillation::setOptionValue(const char *ival)
00027 {
00028         option = (!stricmp(ival, on));
00029 }
00030 
00031 const char *UTF8Cantillation::getOptionValue()
00032 {
00033         return (option) ? on:off;
00034 }
00035 
00036 char UTF8Cantillation::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
00037 {
00038         if (!option) {
00039         unsigned char *to, *from;
00040         to = (unsigned char*)text;
00041         //The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
00042         for (from = (unsigned char*)text; *from; from++) {
00043           if (*from != 0xD6) {
00044             if (*from == 0xD7 && *(from + 1) == 0x84) {
00045               from++;
00046             }
00047             else {
00048               *to++ = *from;
00049             }
00050           }
00051           else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {
00052             *to++ = *from;
00053             from++;
00054             *to++ = *from;
00055           }
00056           else {
00057                 from++;
00058           }
00059         }
00060         *to++ = 0;
00061         *to = 0;
00062      }
00063         return 0;
00064 }

Generated on Thu Jun 20 22:13:01 2002 for The Sword Project by doxygen1.2.15