~ubuntu-branches/debian/squeeze/sword/squeeze

« back to all changes in this revision

Viewing changes to src/modules/filters/utf8cantillation.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Glassey
  • Date: 2004-01-15 15:50:07 UTC
  • Revision ID: james.westby@ubuntu.com-20040115155007-n9mz4x0zxrs1isd3
Tags: upstream-1.5.7
ImportĀ upstreamĀ versionĀ 1.5.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 *
 
3
 * UTF8Cantillation - SWFilter descendant to remove UTF-8 Hebrew cantillation
 
4
 *
 
5
 */
 
6
 
 
7
 
 
8
#include <stdlib.h>
 
9
#include <stdio.h>
 
10
#include <utf8cantillation.h>
 
11
 
 
12
SWORD_NAMESPACE_START
 
13
 
 
14
const char oName[] = "Hebrew Cantillation";
 
15
const char oTip[] = "Toggles Hebrew Cantillation Marks";
 
16
 
 
17
const SWBuf choices[3] = {"On", "Off", ""};
 
18
const StringList oValues(&choices[0], &choices[2]);
 
19
 
 
20
UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, &oValues) {
 
21
        setOptionValue("Off");
 
22
}
 
23
 
 
24
 
 
25
UTF8Cantillation::~UTF8Cantillation(){};
 
26
 
 
27
 
 
28
char UTF8Cantillation::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
 
29
        if (!option) {
 
30
                //The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
 
31
                SWBuf orig = text;
 
32
                const unsigned char* from = (unsigned char*)orig.c_str();
 
33
                for (text = ""; *from; from++) {
 
34
                        if (*from != 0xD6) {
 
35
                                if (*from == 0xD7 && *(from + 1) == 0x84) {
 
36
                                        from++;
 
37
                                }
 
38
                                else {
 
39
                                        text += *from;
 
40
                                }
 
41
                        }
 
42
                        else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {
 
43
                                text += *from;
 
44
                                from++;
 
45
                                text += *from;
 
46
                        }
 
47
                        else {
 
48
                                from++;
 
49
                        }
 
50
                }
 
51
        }
 
52
        return 0;
 
53
}
 
54
 
 
55
SWORD_NAMESPACE_END