$text = str_replace($tol . "ை", "‌‍‌ை" . $tol, $text);
    }
    foreach ($granthalet as $gl) {
        $text = str_replace($gl . "ி", $gl . "ি", $text);
        $text = str_replace($gl . "ீ", $gl . "ী", $text);
        $text = str_replace($gl . "ை", "‌‍‌ை" . $gl, $text);
        $text = str_replace($gl . "ெ", "‌‍‌ெ" . $gl, $text);
        $text = str_replace($gl . "ே", "‌‍‌ே" . $gl, $text);
        $text = str_replace($gl . "ொ", "‌‍‌ெ" . $gl . "ா", $text);
        $text = str_replace($gl . "ோ", "‌‍‌ே" . $gl . "ா", $text);
        $text = str_replace($gl . "ௌ", "ெ" . $gl . "ௗ", $text);
        $text = str_replace("শ்ரீ", "", $text);
    }
}
if ($_SESSION['tgt'] == "egrantha") {
    $text = swap_ey($main['scr'], array(""), $text);
    foreach ($main['scr'] as $gr) {
        $text = str_replace($gr . "", "" . $gr . "া", $text);
    }
    $text = str_replace("়্", "়্‌", $text);
    // Avoid Conjuncts with Nukta
}
// Mark Varga 1 letteers
if ($_SESSION['tavarga1'] == 1 && $_SESSION['tgt'] == 'dtamil') {
    $vargalet = array("க", "ச", "ட", "த", "ப", "ஜ");
    foreach ($vargalet as $varg) {
        $text = str_replace($varg, $varg . "¹", $text);
        //todo
        // Reverse Paris K1a -> Ka1
        $text = swap($SuperNumeral, array($v), $text);
        $text = swap($SuperNumeral, $yukta['scr'], $text);
$text = str_replace($half['tra'], $half['scr'], $text);
$text = str_replace($num['tra'], $num['scr'], " " . $text . " ");
$text = str_replace($v . $main['scr'][154], $main['scr'][154], $text);
// Fix nuktas
/* Crunch remaining full vowels, e.g. ha_uk  and sei */
foreach ($vow['tra'] as $key => $val) {
    $objscr = str_replace(" ", "", $val);
    $objtra = str_replace(" ", "", $vow['scr'][$key]);
    $text = str_replace("{$objscr}", "{$objtra}", $text);
}
$tidys = array("_ ", "- ", "\n ");
$tidyr = array("", "-", "\n");
$text = trim(str_replace($tidys, $tidyr, $text));
/* Add an Extra New line at the End */
$text = $text . "\n";
/* Correct the Virama that appears with quoted Avagraha */
$text = str_replace("'" . $v, "'", $text);
/* Swap diacritic numerals & the vowel sign pairs */
/* e.g கீ² <-- க²ீ */
$text = swap($SuperNumeral, array($v), $text);
$text = swap($SuperNumeral, $yukta['scr'], $text);
$text = swap($SuperNumeralNM, array($main['scr']['149'], $main['scr']['151']), $text);
/* Correct  న·ం misplacements using ZWJ */
/* Reverse Swap...  The Anusvara & Chandrabindu Parts */
if ($_SESSION['tgt'] == "dtamil") {
    $text = swap(array($main['scr']['149'], $main['scr']['151']), $SuperNumeral, $text);
}
/* Swap Vowel Signs in Thai for E, ai, o eY to ye ยเ -> เย */
if ($_SESSION['tgt'] == "thai") {
    $text = swap_ey($main['scr'], array($yukta['scr']['311'], $yukta['scr']['312'], $yukta['scr']['313']), $text);
}