function convert_to_unicode() {
if(document.getElementById("option1").selected) { var array_one = new Array( // ignore all nuktas except in ड़ and ढ़ "[", "]", "‘", "’", "“", "”", "%", "{", "}", "/", ":", "=", "।", "?", "-", "µ", "॰", ",", ".", "् ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "०", "१", "२", "३", "४", "५", "६", "७", "८", "९", "x","+", ";",
"फ़्", "क़", "ख़", "ग़", "ज़्", "ज़", "ड़", "ढ़", "फ़", "य़", "ऱ", "ऩ", // one-byte nukta varNas "त्त्", "त्त", "क्त", "दृ", "कृ",
"ह्न", "ह्य", "हृ", "ह्म", "ह्र", "ह्", "द्द", "क्ष्", "क्ष", "त्र्", "त्र","ज्ञ","द्म", "छ्य", "ट्य", "ठ्य", "ड्य", "ढ्य", "द्य","द्व", "श्र", "ट्र", "ड्र", "ढ्र", "छ्र", "क्र", "फ्र", "द्र", "प्र", "ग्र", "रु", "रू", "्र",
"ओ", "औ", "आ", "अ", "ई", "इ", "उ", "ऊ", "ऐ", "ए", "ऋ",
"क्", "क", "क्क", "ख्", "ख", "ग्", "ग", "घ्", "घ", "ङ", "चै", "च्", "च", "छ", "ज्", "ज", "झ्", "झ", "ञ",
"ट्ट", "ट्ठ", "ट", "ठ", "ड्ड", "ड्ढ", "ड", "ढ", "ण्", "ण", "त्", "त", "थ्", "थ", "द्ध", "द", "ध्", "ध", "न्", "न",
"प्", "प", "फ्", "फ", "ब्", "ब", "भ्", "भ", "म्", "म", "य्", "य", "र", "ल्", "ल", "ळ", "व्", "व", "श्", "श", "ष्", "ष", "स्", "स", "ह",
"ऑ", "ॉ", "ो", "ौ", "ा", "ी", "ु", "ू", "ृ", "े", "ै", "ं", "ँ", "ः", "ॅ", "ऽ", "् ", "्" )
var array_two = new Array(
"¹", "º", "^", "*", "¶", "¸", "»", "¹", "º", "@", "%", "¾", "A", "\\", "&", "&", "Œ", "]","-","~ ", "ú", "û", "ü", "ý", "þ", "ÿ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ", "ö", "÷", "ø", "ù","ñ","$", "_",
"Ý", "d", "[k", "x", "T", "t", "M+", "< +", "iQ", ";", "j", "u", "Ù", "Ùk", "ÙkQ", "n`", "Ñ", "É", "á", "â", "ã", "ß", "Þ", "í", "{", "{k", "=", "=k","K", "Á", "NÔ", "VÔ", "BÔ", "MÔ", "<Ô", "|","}", "J", "Vª", "Mª", "<ªª", "Nª", "Ø", "Ú", "æ", "ç", "xz", "#", ":", "z", "vks", "vkS", "vk", "v", "bZ", "b", "m", "Å", ",s", ",", "½", "D", "d", "éï", "[", "•", "X", "x", "?", "?k", "Ä", "pkS", "P", "p", "N", "T", "t", "Ö", ">", "×k",
"êð", "êò", "V", "B", "îó", "îô", "M", "< ", ".", ".k", "R", "r", "F", "Fk", "¼", "n", "è", "/", "U", "u", "I", "i", "Ý", "iQ", "C", "c", "H", "Hk", "E", "e", "Õ", ";", "j", "Y", "y", "G", "O", "o", "'", "'k", "\"", "\"k", "L", "l", "g", "vkW", "kW", "ks", "kS", "k", "h", "q", "w", "`", "s", "S", "a", "¡", "%", "W", "¿", "~ ", "~") // "~j" //************************************************************ //Put "Enter chunk size:" line before "
//************************************************************ // The following two characters are to be replaced through proper checking of locations:
// "र्" (reph) // "Z" )
// "ि" // "f" )
var array_one_length = array_one.length ;
var modified_substring = document.getElementById("unicode_text").value ;
//**************************************************************************************** // Break the long text into small bunches of max. max_text_size characters each. //**************************************************************************************** var text_size = document.getElementById("unicode_text").value.length ;
var processed_text = '' ; //blank
var sthiti1 = 0 ; var sthiti2 = 0 ; var chale_chalo = 1 ;
var max_text_size = 6000;
//************************************************************ // var max_text_size = chunksize; // alert(max_text_size); //************************************************************
while ( chale_chalo == 1 ) { sthiti1 = sthiti2 ;
if ( sthiti2 < ( text_size - max_text_size ) ) { sthiti2 += max_text_size ; while (document.getElementById("unicode_text").value.charAt ( sthiti2 ) != ' ') {sthiti2--;} } else { sthiti2 = text_size ; chale_chalo = 0 } var modified_substring = document.getElementById("unicode_text").value.substring ( sthiti1, sthiti2 ) ; Replace_Symbols( ) ; processed_text += modified_substring ; //**************************************************************************************** // Breaking part code over //**************************************************************************************** // processed_text = processed_text.replace( /mangal/g , "Krutidev010" ) ; document.getElementById("legacy_text").value = processed_text ; } //************************************************** function Replace_Symbols( ) { // if string to be converted is non-blank then no need of any processing. if (modified_substring != "" ) { // first replace the two-byte nukta_varNa with corresponding one-byte nukta varNas. modified_substring = modified_substring.replace ( /त्र्य/g , "«य" ) ; modified_substring = modified_substring.replace ( /श्र्य/g , "Üzय" ) ; modified_substring = modified_substring.replace ( /क़/ , "क़" ) ; modified_substring = modified_substring.replace ( /ख़/g , "ख़" ) ; modified_substring = modified_substring.replace ( /ग़/g , "ग़" ) ; modified_substring = modified_substring.replace ( /ज़/g , "ज़" ) ; modified_substring = modified_substring.replace ( /ड़/g , "ड़" ) ; modified_substring = modified_substring.replace ( /ढ़/g , "ढ़" ) ; modified_substring = modified_substring.replace ( /ऩ/g , "ऩ" ) ; modified_substring = modified_substring.replace ( /फ़/g , "फ़" ) ; modified_substring = modified_substring.replace ( /य़/g , "य़" ) ; modified_substring = modified_substring.replace ( /ऱ/g , "ऱ" ) ; // code for replacing "ि" (chhotee ee kii maatraa) with "f" and correcting its position too. var position_of_f = modified_substring.indexOf( "ि" ) ; while ( position_of_f != -1 ) //while-02 { var character_left_to_f = modified_substring.charAt( position_of_f - 1 ) ; modified_substring = modified_substring.replace( character_left_to_f + "ि" , "f" + character_left_to_f ) ; position_of_f = position_of_f - 1 ; while (( modified_substring.charAt( position_of_f - 1 ) == "्" ) & ( position_of_f != 0 ) ) { var string_to_be_replaced = modified_substring.charAt( position_of_f - 2 ) + "्" ; modified_substring = modified_substring.replace( string_to_be_replaced + "f", "f" + string_to_be_replaced ) ; position_of_f = position_of_f - 2 ; } position_of_f = modified_substring.search( /ि/ , position_of_f + 1 ) ; // search for f ahead of the current position. } // end of while-02 loop //************************************************************ // modified_substring = modified_substring.replace( /fर्/g , "£" ) ; //************************************************************ // Eliminating "र्" and putting Z at proper position for this. set_of_matras = "ािीुूृेैोौं:ँॅ" modified_substring += ' ' ; // add two spaces after the string to avoid UNDEFINED char in the following code. var position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert(" 21. position_of_half_R = " + position_of_half_R); //************************************************************************************ while ( position_of_half_R > 0 ) // while-03 { // "र्" is two bytes long var probable_position_of_Z = position_of_half_R + 2 ; var character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z )
// alert(" 3. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 4. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
// trying to find non-maatra position right to probable_position_of_Z .
while( set_of_matras.match( character_at_probable_position_of_Z ) != null ) // while-04 { probable_position_of_Z = probable_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 5. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 6. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z ); } // end of while-04 //************************************************************ // check if the next character is a halant //************************************************************ var right_to_position_of_Z = probable_position_of_Z + 1 ; // alert(" 7. right_to_position_of_Z = "+right_to_position_of_Z );
if (right_to_position_of_Z > 0) // if-03 { var character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z ) // alert(" 8. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); // while ("्".match( character_right_to_position_of_Z ) != null ) // while-05
while ( character_right_to_position_of_Z == "्" ) // while-05 { // halant found, move to next character probable_position_of_Z = right_to_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 9. probable_position_of_Z = "+probable_position_of_Z ); // alert("10. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
right_to_position_of_Z = probable_position_of_Z + 1 ; character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z )
// alert("11. right_to_position_of_Z = "+right_to_position_of_Z ); // alert("12. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); } // end of while-05
// alert("121. position_of_half_R = "+position_of_half_R); // alert("122. probable_position_of_Z = "+probable_position_of_Z);
} // end of if-03 //************************************************************
string_to_be_replaced = modified_substring.substr ( position_of_half_R + 2,(probable_position_of_Z - position_of_half_R)-1) ; //************************************************************ // check if character_right_to_position_of_Z is a space // if (space.match(character_right_to_position_of_Z) != null) // { // string_to_be_replaced = string_to_be_replaced.substr(0,string_to_be_replaced.length - 1) // alert("13. string_to_be_replaced = "+string_to_be_replaced ); // alert("14. string_to_be_replaced.length ="+string_to_be_replaced.length); // } modified_substring = modified_substring.replace( "र्" + string_to_be_replaced, string_to_be_replaced + "Z" ) ;
// alert("15. string_to_be_replaced = "+string_to_be_replaced ); // alert("16. modified_substring = "+modified_substring ); position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert("17. position_of_half_R = "+position_of_half_R )
} // end of while-03 //*********************************************************** modified_substring = modified_substring.substr ( 0 , modified_substring.length - 2 ) ;
//substitute array_two elements in place of corresponding array_one elements
for( input_symbol_idx = 0; input_symbol_idx < array_one_length; input_symbol_idx++ ) { idx = 0 ; // index of the symbol being searched for replacement while (idx != -1 ) //whie-00 { modified_substring = modified_substring.replace( array_one[ input_symbol_idx ] , array_two[input_symbol_idx] ) idx = modified_substring.indexOf( array_one[input_symbol_idx] ) } // end of while-00 loop } // end of for loop } // end of IF statement meant to supress processing of blank string. modified_substring = modified_substring.replace( /Zksa/g , "ks±" ) ; modified_substring = modified_substring.replace( /~ Z/g , "Z~" ) ; modified_substring = modified_substring.replace( /Zk/g , "kZ" ) ; modified_substring = modified_substring.replace( /Zh/g , "hZ" ) ; modified_substring = modified_substring.replace( /aZ/g , "±" ) ; } // end of the function Replace_Symbols( ) }else if(document.getElementById("option2").selected) { var array_one = new Array( // ignore all nuktas except in ड़ and ढ़ "[", "]", "‘", "’", "“", "”", "%", "{", "}", "/", ":", "=", "।", "?", "-", "µ", "॰", ",", ".", "् ", "०", "१", "२", "३", "४", "५", "६", "७", "८", "९", "x","+", ";", "फ़्", "क़", "ख़", "ग़", "ज़्", "ज़", "ड़", "ढ़", "फ़", "य़", "ऱ", "ऩ", // one-byte nukta varNas "त्त्", "त्त", "क्त", "दृ", "कृ", "ह्न", "ह्य", "हृ", "ह्म", "ह्र", "ह्", "द्द", "क्ष्", "क्ष", "त्र्", "त्र","ज्ञ","द्म", "छ्य", "ट्य", "ठ्य", "ड्य", "ढ्य", "द्य","द्व", "श्र", "ट्र", "ड्र", "ढ्र", "छ्र", "क्र", "फ्र", "द्र", "प्र", "ग्र", "रु", "रू", "्र", "ओ", "औ", "आ", "अ", "ई", "इ", "उ", "ऊ", "ऐ", "ए", "ऋ", "क्", "क", "क्क", "ख्", "ख", "ग्", "ग", "घ्", "घ", "ङ", "चै", "च्", "च", "छ", "ज्", "ज", "झ्", "झ", "ञ", "ट्ट", "ट्ठ", "ट", "ठ", "ड्ड", "ड्ढ", "ड", "ढ", "ण्", "ण", "त्", "त", "थ्", "थ", "द्ध", "द", "ध्", "ध", "न्", "न", "प्", "प", "फ्", "फ", "ब्", "ब", "भ्", "भ", "म्", "म", "य्", "य", "र", "ल्", "ल", "ळ", "व्", "व", "श्", "श", "ष्", "ष", "स्", "स", "ह", "ऑ", "ॉ", "ो", "ौ", "ा", "ी", "ु", "ू", "ृ", "े", "ै", "ं", "ँ", "ः", "ॅ", "ऽ", "् ", "्" ) var array_two = new Array( "¹", "º", "^", "*", "¶", "¸", "»", "¹", "º", "@", "%", "¾", "A", "\\", "&", "&", "Œ", "]","-","~ ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9","ñ","$", "_", "Ý", "d", "[k", "x", "T", "t", "M+", "<+", "iQ", ";", "j", "u", "Ù", "Ùk", "ÙkQ", "n`", "Ñ", "É", "á", "â", "ã", "ß", "Þ", "í", "{", "{k", "=", "=k","K", "Á", "NÔ", "VÔ", "BÔ", "MÔ", "<Ô", "|","}", "J", "Vª", "Mª", "<ªª", "Nª", "Ø", "Ú", "æ", "ç", "xz", "#", ":", "z", "vks", "vkS", "vk", "v", "bZ", "b", "m", "Å", ",s", ",", "½", "D", "d", "éï", "[", "•", "X", "x", "?", "?k", "Ä", "pkS", "P", "p", "N", "T", "t", "Ö", ">", "×k",
"êð", "êò", "V", "B", "îó", "îô", "M", "< ", ".", ".k", "R", "r", "F", "Fk", "¼", "n", "è", "/", "U", "u", "I", "i", "Ý", "iQ", "C", "c", "H", "Hk", "E", "e", "Õ", ";", "j", "Y", "y", "G", "O", "o", "'", "'k", "\"", "\"k", "L", "l", "g", "vkW", "kW", "ks", "kS", "k", "h", "q", "w", "`", "s", "S", "a", "¡", "%", "W", "¿", "~ ", "~") // "~j" //************************************************************ //Put "Enter chunk size:" line before "
//************************************************************ // The following two characters are to be replaced through proper checking of locations:
// "र्" (reph) // "Z" )
// "ि" // "f" )
var array_one_length = array_one.length ;
var modified_substring = document.getElementById("unicode_text").value ;
//**************************************************************************************** // Break the long text into small bunches of max. max_text_size characters each. //**************************************************************************************** var text_size = document.getElementById("unicode_text").value.length ;
var processed_text = '' ; //blank
var sthiti1 = 0 ; var sthiti2 = 0 ; var chale_chalo = 1 ;
var max_text_size = 6000;
//************************************************************ // var max_text_size = chunksize; // alert(max_text_size); //************************************************************
while ( chale_chalo == 1 ) { sthiti1 = sthiti2 ;
if ( sthiti2 < ( text_size - max_text_size ) ) { sthiti2 += max_text_size ; while (document.getElementById("unicode_text").value.charAt ( sthiti2 ) != ' ') {sthiti2--;} } else { sthiti2 = text_size ; chale_chalo = 0 } var modified_substring = document.getElementById("unicode_text").value.substring ( sthiti1, sthiti2 ) ; Replace_Symbols( ) ; processed_text += modified_substring ; //**************************************************************************************** // Breaking part code over //**************************************************************************************** // processed_text = processed_text.replace( /mangal/g , "Krutidev010" ) ; document.getElementById("legacy_text").value = processed_text ; } //************************************************** function Replace_Symbols( ) { // if string to be converted is non-blank then no need of any processing. if (modified_substring != "" ) { // first replace the two-byte nukta_varNa with corresponding one-byte nukta varNas. modified_substring = modified_substring.replace ( /त्र्य/g , "«य" ) ; modified_substring = modified_substring.replace ( /श्र्य/g , "Üzय" ) ; modified_substring = modified_substring.replace ( /क़/ , "क़" ) ; modified_substring = modified_substring.replace ( /ख़/g , "ख़" ) ; modified_substring = modified_substring.replace ( /ग़/g , "ग़" ) ; modified_substring = modified_substring.replace ( /ज़/g , "ज़" ) ; modified_substring = modified_substring.replace ( /ड़/g , "ड़" ) ; modified_substring = modified_substring.replace ( /ढ़/g , "ढ़" ) ; modified_substring = modified_substring.replace ( /ऩ/g , "ऩ" ) ; modified_substring = modified_substring.replace ( /फ़/g , "फ़" ) ; modified_substring = modified_substring.replace ( /य़/g , "य़" ) ; modified_substring = modified_substring.replace ( /ऱ/g , "ऱ" ) ; // code for replacing "ि" (chhotee ee kii maatraa) with "f" and correcting its position too. var position_of_f = modified_substring.indexOf( "ि" ) ; while ( position_of_f != -1 ) //while-02 { var character_left_to_f = modified_substring.charAt( position_of_f - 1 ) ; modified_substring = modified_substring.replace( character_left_to_f + "ि" , "f" + character_left_to_f ) ; position_of_f = position_of_f - 1 ; while (( modified_substring.charAt( position_of_f - 1 ) == "्" ) & ( position_of_f != 0 ) ) { var string_to_be_replaced = modified_substring.charAt( position_of_f - 2 ) + "्" ; modified_substring = modified_substring.replace( string_to_be_replaced + "f", "f" + string_to_be_replaced ) ; position_of_f = position_of_f - 2 ; } position_of_f = modified_substring.search( /ि/ , position_of_f + 1 ) ; // search for f ahead of the current position. } // end of while-02 loop //************************************************************ // modified_substring = modified_substring.replace( /fर्/g , "£" ) ; //************************************************************ // Eliminating "र्" and putting Z at proper position for this. set_of_matras = "ािीुूृेैोौं:ँॅ" modified_substring += ' ' ; // add two spaces after the string to avoid UNDEFINED char in the following code. var position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert(" 21. position_of_half_R = " + position_of_half_R); //************************************************************************************ while ( position_of_half_R > 0 ) // while-03 { // "र्" is two bytes long var probable_position_of_Z = position_of_half_R + 2 ; var character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z )
// alert(" 3. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 4. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
// trying to find non-maatra position right to probable_position_of_Z .
while( set_of_matras.match( character_at_probable_position_of_Z ) != null ) // while-04 { probable_position_of_Z = probable_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 5. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 6. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z ); } // end of while-04 //************************************************************ // check if the next character is a halant //************************************************************ var right_to_position_of_Z = probable_position_of_Z + 1 ; // alert(" 7. right_to_position_of_Z = "+right_to_position_of_Z );
if (right_to_position_of_Z > 0) // if-03 { var character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z ) // alert(" 8. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); // while ("्".match( character_right_to_position_of_Z ) != null ) // while-05
while ( character_right_to_position_of_Z == "्" ) // while-05 { // halant found, move to next character probable_position_of_Z = right_to_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 9. probable_position_of_Z = "+probable_position_of_Z ); // alert("10. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
right_to_position_of_Z = probable_position_of_Z + 1 ; character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z )
// alert("11. right_to_position_of_Z = "+right_to_position_of_Z ); // alert("12. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); } // end of while-05
// alert("121. position_of_half_R = "+position_of_half_R); // alert("122. probable_position_of_Z = "+probable_position_of_Z);
} // end of if-03 //************************************************************
string_to_be_replaced = modified_substring.substr ( position_of_half_R + 2,(probable_position_of_Z - position_of_half_R)-1) ; //************************************************************ // check if character_right_to_position_of_Z is a space // if (space.match(character_right_to_position_of_Z) != null) // { // string_to_be_replaced = string_to_be_replaced.substr(0,string_to_be_replaced.length - 1) // alert("13. string_to_be_replaced = "+string_to_be_replaced ); // alert("14. string_to_be_replaced.length ="+string_to_be_replaced.length); // } modified_substring = modified_substring.replace( "र्" + string_to_be_replaced, string_to_be_replaced + "Z" ) ;
// alert("15. string_to_be_replaced = "+string_to_be_replaced ); // alert("16. modified_substring = "+modified_substring ); position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert("17. position_of_half_R = "+position_of_half_R )
} // end of while-03 //*********************************************************** modified_substring = modified_substring.substr ( 0 , modified_substring.length - 2 ) ;
//substitute array_two elements in place of corresponding array_one elements
for( input_symbol_idx = 0; input_symbol_idx < array_one_length; input_symbol_idx++ ) { idx = 0 ; // index of the symbol being searched for replacement while (idx != -1 ) //whie-00 { modified_substring = modified_substring.replace( array_one[ input_symbol_idx ] , array_two[input_symbol_idx] ) idx = modified_substring.indexOf( array_one[input_symbol_idx] ) } // end of while-00 loop } // end of for loop } // end of IF statement meant to supress processing of blank string. modified_substring = modified_substring.replace( /Zksa/g , "ks±" ) ; modified_substring = modified_substring.replace( /~ Z/g , "Z~" ) ; modified_substring = modified_substring.replace( /Zk/g , "kZ" ) ; modified_substring = modified_substring.replace( /Zh/g , "hZ" ) ; modified_substring = modified_substring.replace( /aZ/g , "±" ) ; } // end of the function Replace_Symbols }else if(document.getElementById("option3").selected) { var array_one = new Array( // ignore all nuktas except in ड़ and ढ़ "[", "]", "‘", "’", "“", "”", "%", "{", "}", "/", ":", "=", "।", "?", "-", "µ", "॰", ",", ".", "् ", "०", "१", "२", "३", "४", "५", "६", "७", "८", "९", "x","+", ";", "फ़्", "क़", "ख़", "ग़", "ज़्", "ज़", "ड़", "ढ़", "फ़", "य़", "ऱ", "ऩ", // one-byte nukta varNas "त्त्", "त्त", "क्त", "दृ", "कृ", "ह्न", "ह्य", "हृ", "ह्म", "ह्र", "ह्", "द्द", "क्ष्", "क्ष", "त्र्", "त्र","ज्ञ","द्म", "छ्य", "ट्य", "ठ्य", "ड्य", "ढ्य", "द्य","द्व", "श्र", "ट्र", "ड्र", "ढ्र", "छ्र", "क्र", "फ्र", "द्र", "प्र", "ग्र", "रु", "रू", "्र", "ओ", "औ", "आ", "अ", "ई", "इ", "उ", "ऊ", "ऐ", "ए", "ऋ", "क्", "क", "क्क", "ख्", "ख", "ग्", "ग", "घ्", "घ", "ङ", "चै", "च्", "च", "छ", "ज्", "ज", "झ्", "झ", "ञ", "ट्ट", "ट्ठ", "ट", "ठ", "ड्ड", "ड्ढ", "ड", "ढ", "ण्", "ण", "त्", "त", "थ्", "थ", "द्ध", "द", "ध्", "ध", "न्", "न", "प्", "प", "फ्", "फ", "ब्", "ब", "भ्", "भ", "म्", "म", "य्", "य", "र", "ल्", "ल", "ळ", "व्", "व", "श्", "श", "ष्", "ष", "स्", "स", "ह", "ऑ", "ॉ", "ो", "ौ", "ा", "ी", "ु", "ू", "ृ", "े", "ै", "ं", "ँ", "ः", "ॅ", "ऽ", "् ", "्" ) var array_two = new Array( "¹", "º", "^", "*", "¶", "¸", "»", "¹", "º", "@", "%", "¾", "A", "\\", "&", "&", "Œ", "]","-","~ ", "ú", "û", "ü", "ý", "þ", "ÿ", "ö", "÷", "ø", "ù","ñ","$", "_", "Ý", "d", "[k", "x", "T", "t", "M+", "<+", "iQ", ";", "j", "u", "Ù", "Ùk", "ÙkQ", "n`", "Ñ", "É", "á", "â", "ã", "ß", "Þ", "í", "{", "{k", "=", "=k","K", "Á", "NÔ", "VÔ", "BÔ", "MÔ", "<Ô", "|","}", "J", "Vª", "Mª", "<ªª", "Nª", "Ø", "Ú", "æ", "ç", "xz", "#", ":", "z", "vks", "vkS", "vk", "v", "bZ", "b", "m", "Å", ",s", ",", "½", "D", "d", "éï", "[", "•", "X", "x", "?", "?k", "Ä", "pkS", "P", "p", "N", "T", "t", "Ö", ">", "×k",
"êð", "êò", "V", "B", "îó", "îô", "M", "< ", ".", ".k", "R", "r", "F", "Fk", "¼", "n", "è", "/", "U", "u", "I", "i", "Ý", "iQ", "C", "c", "H", "Hk", "E", "e", "Õ", ";", "j", "Y", "y", "G", "O", "o", "'", "'k", "\"", "\"k", "L", "l", "g", "vkW", "kW", "ks", "kS", "k", "h", "q", "w", "`", "s", "S", "a", "¡", "%", "W", "¿", "~ ", "~") // "~j" //************************************************************ //Put "Enter chunk size:" line before "
//************************************************************ // The following two characters are to be replaced through proper checking of locations:
// "र्" (reph) // "Z" )
// "ि" // "f" )
var array_one_length = array_one.length ;
var modified_substring = document.getElementById("unicode_text").value ;
//**************************************************************************************** // Break the long text into small bunches of max. max_text_size characters each. //**************************************************************************************** var text_size = document.getElementById("unicode_text").value.length ;
var processed_text = '' ; //blank
var sthiti1 = 0 ; var sthiti2 = 0 ; var chale_chalo = 1 ;
var max_text_size = 6000;
//************************************************************ // var max_text_size = chunksize; // alert(max_text_size); //************************************************************
while ( chale_chalo == 1 ) { sthiti1 = sthiti2 ;
if ( sthiti2 < ( text_size - max_text_size ) ) { sthiti2 += max_text_size ; while (document.getElementById("unicode_text").value.charAt ( sthiti2 ) != ' ') {sthiti2--;} } else { sthiti2 = text_size ; chale_chalo = 0 } var modified_substring = document.getElementById("unicode_text").value.substring ( sthiti1, sthiti2 ) ; Replace_Symbols( ) ; processed_text += modified_substring ; //**************************************************************************************** // Breaking part code over //**************************************************************************************** // processed_text = processed_text.replace( /mangal/g , "Krutidev010" ) ; document.getElementById("legacy_text").value = processed_text ; } //************************************************** function Replace_Symbols( ) { // if string to be converted is non-blank then no need of any processing. if (modified_substring != "" ) { // first replace the two-byte nukta_varNa with corresponding one-byte nukta varNas. modified_substring = modified_substring.replace ( /त्र्य/g , "«य" ) ; modified_substring = modified_substring.replace ( /श्र्य/g , "Üzय" ) ; modified_substring = modified_substring.replace ( /क़/ , "क़" ) ; modified_substring = modified_substring.replace ( /ख़/g , "ख़" ) ; modified_substring = modified_substring.replace ( /ग़/g , "ग़" ) ; modified_substring = modified_substring.replace ( /ज़/g , "ज़" ) ; modified_substring = modified_substring.replace ( /ड़/g , "ड़" ) ; modified_substring = modified_substring.replace ( /ढ़/g , "ढ़" ) ; modified_substring = modified_substring.replace ( /ऩ/g , "ऩ" ) ; modified_substring = modified_substring.replace ( /फ़/g , "फ़" ) ; modified_substring = modified_substring.replace ( /य़/g , "य़" ) ; modified_substring = modified_substring.replace ( /ऱ/g , "ऱ" ) ; // code for replacing "ि" (chhotee ee kii maatraa) with "f" and correcting its position too. var position_of_f = modified_substring.indexOf( "ि" ) ; while ( position_of_f != -1 ) //while-02 { var character_left_to_f = modified_substring.charAt( position_of_f - 1 ) ; modified_substring = modified_substring.replace( character_left_to_f + "ि" , "f" + character_left_to_f ) ; position_of_f = position_of_f - 1 ; while (( modified_substring.charAt( position_of_f - 1 ) == "्" ) & ( position_of_f != 0 ) ) { var string_to_be_replaced = modified_substring.charAt( position_of_f - 2 ) + "्" ; modified_substring = modified_substring.replace( string_to_be_replaced + "f", "f" + string_to_be_replaced ) ; position_of_f = position_of_f - 2 ; } position_of_f = modified_substring.search( /ि/ , position_of_f + 1 ) ; // search for f ahead of the current position. } // end of while-02 loop //************************************************************ // modified_substring = modified_substring.replace( /fर्/g , "£" ) ; //************************************************************ // Eliminating "र्" and putting Z at proper position for this. set_of_matras = "ािीुूृेैोौं:ँॅ" modified_substring += ' ' ; // add two spaces after the string to avoid UNDEFINED char in the following code. var position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert(" 21. position_of_half_R = " + position_of_half_R); //************************************************************************************ while ( position_of_half_R > 0 ) // while-03 { // "र्" is two bytes long var probable_position_of_Z = position_of_half_R + 2 ; var character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z )
// alert(" 3. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 4. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
// trying to find non-maatra position right to probable_position_of_Z .
while( set_of_matras.match( character_at_probable_position_of_Z ) != null ) // while-04 { probable_position_of_Z = probable_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 5. probable_position_of_Z = "+probable_position_of_Z ); // alert(" 6. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z ); } // end of while-04 //************************************************************ // check if the next character is a halant //************************************************************ var right_to_position_of_Z = probable_position_of_Z + 1 ; // alert(" 7. right_to_position_of_Z = "+right_to_position_of_Z );
if (right_to_position_of_Z > 0) // if-03 { var character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z ) // alert(" 8. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); // while ("्".match( character_right_to_position_of_Z ) != null ) // while-05
while ( character_right_to_position_of_Z == "्" ) // while-05 { // halant found, move to next character probable_position_of_Z = right_to_position_of_Z + 1 ; character_at_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z ) ;
// alert(" 9. probable_position_of_Z = "+probable_position_of_Z ); // alert("10. character_at_probable_position_of_Z = "+character_at_probable_position_of_Z );
right_to_position_of_Z = probable_position_of_Z + 1 ; character_right_to_position_of_Z = modified_substring.charAt( right_to_position_of_Z )
// alert("11. right_to_position_of_Z = "+right_to_position_of_Z ); // alert("12. character_right_to_position_of_Z = "+character_right_to_position_of_Z ); } // end of while-05
// alert("121. position_of_half_R = "+position_of_half_R); // alert("122. probable_position_of_Z = "+probable_position_of_Z);
} // end of if-03 //************************************************************
string_to_be_replaced = modified_substring.substr ( position_of_half_R + 2,(probable_position_of_Z - position_of_half_R)-1) ; //************************************************************ // check if character_right_to_position_of_Z is a space // if (space.match(character_right_to_position_of_Z) != null) // { // string_to_be_replaced = string_to_be_replaced.substr(0,string_to_be_replaced.length - 1) // alert("13. string_to_be_replaced = "+string_to_be_replaced ); // alert("14. string_to_be_replaced.length ="+string_to_be_replaced.length); // } modified_substring = modified_substring.replace( "र्" + string_to_be_replaced, string_to_be_replaced + "Z" ) ;
// alert("15. string_to_be_replaced = "+string_to_be_replaced ); // alert("16. modified_substring = "+modified_substring ); position_of_half_R = modified_substring.indexOf( "र्" ) ; // alert("17. position_of_half_R = "+position_of_half_R )
} // end of while-03 //*********************************************************** modified_substring = modified_substring.substr ( 0 , modified_substring.length - 2 ) ;
//substitute array_two elements in place of corresponding array_one elements
for( input_symbol_idx = 0; input_symbol_idx < array_one_length; input_symbol_idx++ ) { idx = 0 ; // index of the symbol being searched for replacement while (idx != -1 ) //whie-00 { modified_substring = modified_substring.replace( array_one[ input_symbol_idx ] , array_two[input_symbol_idx] ) idx = modified_substring.indexOf( array_one[input_symbol_idx] ) } // end of while-00 loop } // end of for loop } // end of IF statement meant to supress processing of blank string. modified_substring = modified_substring.replace( /Zksa/g , "ks±" ) ; modified_substring = modified_substring.replace( /~ Z/g , "Z~" ) ; modified_substring = modified_substring.replace( /Zk/g , "kZ" ) ; modified_substring = modified_substring.replace( /Zh/g , "hZ" ) ; modified_substring = modified_substring.replace( /aZ/g , "±" ) ; } // end of the function Replace_Symbols( ) } var array_one_length = array_one.length ; var modified_substring = document.getElementById("unicode_text").value ; Replace_Symbols( ) ; processed_text = modified_substring ; document.getElementById("legacy_text").value = processed_text ; // -------------------------------------------------- function Replace_Symbols( ) { //substitute array_two elements in place of corresponding array_one elements if ( modified_substring != "" ) // if stringto be converted is non-blank then no need of any processing. { for ( input_symbol_idx = 0; input_symbol_idx < array_one_length; input_symbol_idx++ ) { idx = 0 ; // index of the symbol being searched for replacement while (idx != -1 ) //while-00 { modified_substring = modified_substring.replace( array_one[ input_symbol_idx ] , array_two[input_symbol_idx] ) idx = modified_substring.indexOf( array_one[input_symbol_idx] ) } // end of while-00 loop } // end of for loop } // end of IF statement meant to supress processing of blank string. } // end of the function Replace_Symbols( ) } // end of convert_to_unicode function