blob: 84cb513b3763cea1b97e1d599947a569caa445db (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/******************************************************************************
*
* UTF8Cantillation - SWFilter decendant to remove UTF-8 Hebrew cantillation
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <utf8cantillation.h>
const char UTF8Cantillation::on[] = "On";
const char UTF8Cantillation::off[] = "Off";
const char UTF8Cantillation::optName[] = "Hebrew Cantillation";
const char UTF8Cantillation::optTip[] = "Toggles Hebrew Cantillation Marks";
UTF8Cantillation::UTF8Cantillation() {
option = false;
options.push_back(on);
options.push_back(off);
}
UTF8Cantillation::~UTF8Cantillation(){};
void UTF8Cantillation::setOptionValue(const char *ival)
{
option = (!stricmp(ival, on));
}
const char *UTF8Cantillation::getOptionValue()
{
return (option) ? on:off;
}
char UTF8Cantillation::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
{
if (!option) {
unsigned char *to, *from;
to = (unsigned char*)text;
//The UTF-8 range 0xD6 0x90 to 0xD6 0xAF and 0xD7 0x84 consist of Hebrew cantillation marks so block those out.
for (from = (unsigned char*)text; *from; from++) {
if (*from != 0xD6) {
if (*from == 0xD7 && *(from + 1) == 0x84) {
from++;
}
else {
*to++ = *from;
}
}
else if (*(from + 1) < 0x90 || *(from + 1) > 0xAF) {
*to++ = *from;
from++;
*to++ = *from;
}
else {
from++;
}
}
*to++ = 0;
*to = 0;
}
return 0;
}
|