Skip to content

Instantly share code, notes, and snippets.

@nautical
Created December 19, 2017 22:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nautical/53c0580a544b43e9d7daf660e0ba930c to your computer and use it in GitHub Desktop.
Save nautical/53c0580a544b43e9d7daf660e0ba930c to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Conversion</title>
<script type="text/javascript">
function convertor() {
var hindi = new Array(
"ñ", "Q+Z", "sas", "aa", ")Z", "ZZ", "‘", "’", "“", "”",
"å", "ƒ", "„", "…", "†", "‡", "ˆ", "‰", "Š", "‹",
"¶+", "d+", "[+k", "[+", "x+", "T+", "t+", "M+", "<+", "Q+", ";+", "j+", "u+",
"Ùk", "Ù", "ä", "–", "—", "é", "™", "=kk", "f=k",
"à", "á", "â", "ã", "ºz", "º", "í", "{k", "{", "=", "«",
"Nî", "Vî", "Bî", "Mî", "<î", "|", "K", "}",
"J", "Vª", "Mª", "<ªª", "Nª", "Ø", "Ý", "nzZ", "æ", "ç", "Á", "xz", "#", ":",
"v‚", "vks", "vkS", "vk", "v", "b±", "Ã", "bZ", "b", "m", "Å", ",s", ",", "_",
"ô", "d", "Dk", "D", "[k", "[", "x", "Xk", "X", "Ä", "?k", "?", "³",
"pkS", "p", "Pk", "P", "N", "t", "Tk", "T", ">", "÷", "¥",
"ê", "ë", "V", "B", "ì", "ï", "M+", "<+", "M", "<", ".k", ".",
"r", "Rk", "R", "Fk", "F", ")", "n", "/k", "èk", "/", "Ë", "è", "u", "Uk", "U",
"i", "Ik", "I", "Q", "¶", "c", "Ck", "C", "Hk", "H", "e", "Ek", "E",
";", "¸", "j", "y", "Yk", "Y", "G", "o", "Ok", "O",
"'k", "'", "\"k", "\"", "l", "Lk", "L", "g",
"È", "z",
"Ì", "Í", "Î", "Ï", "Ñ", "Ò", "Ó", "Ô", "Ö", "Ø", "Ù", "Ük", "Ü",
"‚", "ks", "kS", "k", "h", "q", "w", "`", "s", "S",
"a", "¡", "%", "W", "•", "·", "∙", "·", "~j", "~", "\\", "+", " ः",
"^", "*", "Þ", "ß", "(", "¼", "½", "¿", "À", "¾", "A", "-", "&", "&", "Œ", "]", "~ ", "@")
var uniArr = new Array(
"॰", "QZ+", "sa", "a", "र्द्ध", "Z", "\"", "\"", "'", "'",
"०", "१", "२", "३", "४", "५", "६", "७", "८", "९",
"फ़्", "क़", "ख़", "ख़्", "ग़", "ज़्", "ज़", "ड़", "ढ़", "फ़", "य़", "ऱ", "ऩ",
"त्त", "त्त्", "क्त", "दृ", "कृ", "न्न", "न्न्", "=k", "f=",
"ह्न", "ह्य", "हृ", "ह्म", "ह्र", "ह्", "द्द", "क्ष", "क्ष्", "त्र", "त्र्",
"छ्य", "ट्य", "ठ्य", "ड्य", "ढ्य", "द्य", "ज्ञ", "द्व",
"श्र", "ट्र", "ड्र", "ढ्र", "छ्र", "क्र", "फ्र", "र्द्र", "द्र", "प्र", "प्र", "ग्र", "रु", "रू",
"ऑ", "ओ", "औ", "आ", "अ", "ईं", "ई", "ई", "इ", "उ", "ऊ", "ऐ", "ए", "ऋ",
"क्क", "क", "क", "क्", "ख", "ख्", "ग", "ग", "ग्", "घ", "घ", "घ्", "ङ",
"चै", "च", "च", "च्", "छ", "ज", "ज", "ज्", "झ", "झ्", "ञ",
"ट्ट", "ट्ठ", "ट", "ठ", "ड्ड", "ड्ढ", "ड़", "ढ़", "ड", "ढ", "ण", "ण्",
"त", "त", "त्", "थ", "थ्", "द्ध", "द", "ध", "ध", "ध्", "ध्", "ध्", "न", "न", "न्",
"प", "प", "प्", "फ", "फ्", "ब", "ब", "ब्", "भ", "भ्", "म", "म", "म्",
"य", "य्", "र", "ल", "ल", "ल्", "ळ", "व", "व", "व्",
"श", "श्", "ष", "ष्", "स", "स", "स्", "ह",
"ीं", "्र",
"द्द", "ट्ट", "ट्ठ", "ड्ड", "कृ", "भ", "्य", "ड्ढ", "झ्", "क्र", "त्त्", "श", "श्",
"ॉ", "ो", "ौ", "ा", "ी", "ु", "ू", "ृ", "े", "ै",
"ं", "ँ", "ः", "ॅ", "ऽ", "ऽ", "ऽ", "ऽ", "्र", "्", "?", "़", ":",
"‘", "’", "“", "”", ";", "(", ")", "{", "}", "=", "।", ".", "-", "µ", "॰", ",", "् ", "/")
var hindi_length = hindi.length;
var mod_str = document.getElementById("hindi_text").value;
var text_size = document.getElementById("hindi_text").value.length;
var output = '';
var c1 = 0;
var c2 = 0;
var flag_i = 1;
var bufferSize = 6000;
while (flag_i == 1) {
c1 = c2;
if (c2 < (text_size - bufferSize)) {
c2 += bufferSize;
while (document.getElementById("hindi_text").value.charAt(c2) != ' ') {
c2--;
}
} else {
c2 = text_size;
flag_i = 0
}
var mod_str = document.getElementById("hindi_text").value.substring(c1, c2);
switch_context();
output += mod_str;
document.getElementById("shifted_text").value = output;
}
function switch_context() {
if (mod_str != "") {
for (input_symbol_idx = 0; input_symbol_idx < hindi_length; input_symbol_idx++) {
idx = 0;
while (idx != -1)
{
mod_str = mod_str.replace(hindi[input_symbol_idx], uniArr[input_symbol_idx])
idx = mod_str.indexOf(hindi[input_symbol_idx])
}
}
if(!document.getElementById("simple").checked) perform_font_specific_activities(mod_str);
}
}
function perform_font_specific_activities(){
mod_str = mod_str.replace(/±/g, "Zं");
mod_str = mod_str.replace(/Æ/g, "र्f");
var pos_i = mod_str.indexOf("f")
while (pos_i != -1) {
var i2 = mod_str.charAt(pos_i + 1)
var char_replace = "f" + i2
mod_str = mod_str.replace(char_replace, i2 + "ि")
pos_i = mod_str.search(/f/, pos_i + 1)
}
mod_str = mod_str.replace(/Ç/g, "fa");
mod_str = mod_str.replace(/É/g, "र्fa");
var pos_i = mod_str.indexOf("fa")
while (pos_i != -1) {
var ip2 = mod_str.charAt(pos_i + 2)
var char_replace = "fa" + ip2
mod_str = mod_str.replace(char_replace, ip2 + "िं")
pos_i = mod_str.search(/fa/, pos_i + 2)
}
mod_str = mod_str.replace(/Ê/g, "ीZ");
var wrg_ee = mod_str.indexOf("ि्")
while (wrg_ee != -1) {
var const_wrong_ee = mod_str.charAt(wrg_ee + 2)
var char_replace = "ि्" + const_wrong_ee
mod_str = mod_str.replace(char_replace, "्" + const_wrong_ee + "ि")
wrg_ee = mod_str.search(/ि्/, wrg_ee + 2)
}
matra_list = "अ आ इ ई उ ऊ ए ऐ ओ औ ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ"
var position_of_R = mod_str.indexOf("Z")
while (position_of_R > 0) {
probable_position_halfR = position_of_R - 1;
var probable_halfR = mod_str.charAt(probable_position_halfR)
while (matra_list.match(probable_halfR) != null) {
probable_position_halfR = probable_position_halfR - 1;
probable_halfR = mod_str.charAt(probable_position_halfR);
}
char_replace = mod_str.substr(probable_position_halfR, (position_of_R - probable_position_halfR));
new_replacement_string = "र्" + char_replace;
char_replace = char_replace + "Z";
mod_str = mod_str.replace(char_replace, new_replacement_string);
position_of_R = mod_str.indexOf("Z");
}
}
}
</script>
</head>
<body style="background-color: #f6f6f6;color: #484848;font: 400 13px/21px 'open sans';font-size: 16px;padding:50px">
<form name="form0">
Conversion Level<br>
<input type="radio" name="level" id="simple" checked="checked">Simple<br>
<input type="radio" name="level" id="hard">Hard
</form>
<form name="form1">
<table>
<tr>
<td align='center'>Hindi</td>
<td align='center'><textarea name="TextToConvert" id="hindi_text" cols="50" rows="10"></textarea></td>
</tr>
<tr>
<td align='center'></td>
<td align='center'>
<input type="button" name="converter" id="converter" onClick="convertor();" value="V">
</td>
</tr>
<tr>
<td align='center'>Unicode</td>
<td align='center'><textarea name="ConvertedText" id="shifted_text" cols="50" rows="10"></textarea></td>
</tr>
</table>
</form>
- Nautical
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment