-
Notifications
You must be signed in to change notification settings - Fork 1
/
diCrunch_postprocess.php
67 lines (38 loc) · 1.32 KB
/
diCrunch_postprocess.php
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
65
66
67
<?PHP
/* Exceptions postprocessing */
if (!empty($_POST['src'])) {
/* Evading the ~n to .s (Bal) or .t (CSX) problem by temporary renaming */
if ($_POST['src'] == "balaram" || $_POST['src'] == "csx") {
$text = str_replace("--j--", $ch[$_POST['tgt']]['ex']['7'], $text);
}
/* ITRANS: Evading double replacements
- the long vowel issue with R^I and L^I
- the _D XIAST extension */
if ($_POST['src'] == "itrans") {
$se = array("L^{$ch[$_POST['tgt']]['2']}", "R^{$ch[$_POST['tgt']]['2']}", ".{$ch[$_POST['tgt']]['9']}");
$re = array($ch[$_POST['tgt']]['16'], $ch[$_POST['tgt']]['5'], $ch[$_POST['tgt']]['20']);
$text = str_replace($se, $re, $text);
}
/* Shakti variants */
if ($_POST['src'] == "shakti") {
$se = array("Ã", "", "Ô", "Õ", "Ò", "Ó");
$re = array($ch[$_POST['tgt']][10], $ch[$_POST['tgt']][11], "‘", "’", "“", "”");
$text = str_replace($se, $re, $text);
}
}
$text = str_replace("\n ", "\n", $text);
/* Preference postprocess */
if (!empty($_POST['mstyle'])) {
$text = str_replace("ṁ", "ṃ", $text);
}
/* Process escape character */
function conv_back($char) {
global $ch;
$id = array_search($char, $ch[$_POST['tgt']]);
if ($id > 0) {
$char = $ch[$_POST['src']][$id];
}
return $char;
}
$text = preg_replace("@#(.)@ue", "conv_back('\\1')", $text);
?>