1
/******************************************************************************
3
* UTF8Cantillation - SWFilter descendant to remove UTF-8 Hebrew cantillation
7
* Copyright 2009 CrossWire Bible Society (http://www.crosswire.org)
8
* CrossWire Bible Society
10
* Tempe, AZ 85280-2528
12
* This program is free software; you can redistribute it and/or modify it
13
* under the terms of the GNU General Public License as published by the
14
* Free Software Foundation version 2.
16
* This program is distributed in the hope that it will be useful, but
17
* WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* General Public License for more details.
25
#include <utf8cantillation.h>
29
const char oName[] = "Hebrew Cantillation";
30
const char oTip[] = "Toggles Hebrew Cantillation Marks";
32
const SWBuf choices[3] = {"On", "Off", ""};
33
const StringList oValues(&choices[0], &choices[2]);
35
UTF8Cantillation::UTF8Cantillation() : SWOptionFilter(oName, oTip, &oValues) {
36
setOptionValue("Off");
40
UTF8Cantillation::~UTF8Cantillation(){};
43
char UTF8Cantillation::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
45
//The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
47
const unsigned char* from = (unsigned char*)orig.c_str();
48
for (text = ""; *from; from++) {
50
if (*from == 0xD7 && *(from + 1) == 0x84) {
57
else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {