blob: d878420cae5ac41ef2339fec6d7042b6b42545a5 (
plain)
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
|
#include "../dw/fltkcore.hh"
#include "../dw/hyphenator.hh"
void hyphenateWord (dw::core::Platform *p, const char *word)
{
dw::Hyphenator *h = dw::Hyphenator::getHyphenator (p, "de");
int numBreaks;
int *breakPos = h->hyphenateWord (word, &numBreaks);
for (int i = 0; i < numBreaks + 1; i++) {
if (i != 0)
putchar ('-');
int start = (i == 0 ? 0 : breakPos[i - 1]);
int end = (i == numBreaks ? strlen (word) : breakPos[i]);
for (int j = start; j < end; j++)
putchar (word[j]);
}
putchar ('\n');
if (breakPos)
delete breakPos;
}
int main (int argc, char *argv[])
{
dw::fltk::FltkPlatform p;
hyphenateWord (&p, "Jahrhundertroman");
hyphenateWord (&p, "JAHRHUNDERTROMAN");
hyphenateWord (&p, "währenddessen");
hyphenateWord (&p, "Ückendorf");
hyphenateWord (&p, "über");
hyphenateWord (&p, "aber");
hyphenateWord (&p, "Ackermann");
hyphenateWord (&p, "Grundstücksverkehrsgenehmigungszuständigkeits"
"übertragungsverordnung");
hyphenateWord (&p, "„Grundstücksverkehrsgenehmigungszuständigkeits"
"übertragungsverordnung“");
return 0;
}
|