function ConvertToUnicode(select)
{
	
var inputTextFont = document.getElementById('inputTextFont');
 	inputTextFont.value=select.value;
	inputFontSelected = select.value;
	if(inputFontSelected =='Unicode')
	{
		//Nothing to convert
	}
 	else
	{ 
		if(inputFontSelected =='4CGandhi')
		{
			convert4CGandhi_to_unicode();
		}
		else 
		{
			if(inputFontSelected == 'Krutidev')
			{
				convert_Krutidev10_to_Unicode();
			}
			else 
			{	
				if(inputFontSelected == 'Chanakaya')
				{
					convertChanakya_to_unicode();
				}
				else 
				{
					if(inputFontSelected == 'Kundli')
					{
						convertAmar_to_unicode();
					}
					else 
					{
						if(inputFontSelected == 'Chandni')
						{
							convertChandni_to_unicode();
						}
						else 
						{
							if(inputFontSelected =='Sahara')
							{
								convertSahara_to_unicode();
							}
							else 
							{
								if(inputFontSelected =='Preeti')
								{
									convertPreeti_to_unicode();
								}
								else
								{
									if(inputFontSelected == 'Shreedev702')
									{
										convertShreedev702_to_unicode();		
									}
									else
									{
										if(inputFontSelected == 'Shusha')
										{
											convertShusha_to_unicode();		
										}
										else
										{
											if(inputFontSelected == 'Parkash')
											{
												convertPrakash_to_unicode();		
											}
											else
											{
												if(inputFontSelected == 'DV-TTSurekhEN')
												{
													convertDV_TTSurekhEN_to_unicode();	
												}
												else
												{
													if(inputFontSelected == 'Yuvraj')
													{
														convertYuvraj_to_unicode();	
													}
													else
													{
														document.getElementById('output').value = 'This Font is not Supported';
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}

function convert4CGandhi_to_unicode()
{
var array_one = new Array( 'Ń', 

"X","Y","Û","Ú","Ü","Ý","Ù",

"n","o","p","{","}","~",
"‚","ƒ","„","…","†","‡","ˆ","‰","Š","‹","Œ",
"‘","’","“","”","–","˜","™","š","›","œ",
"¤","¥","©","«",
"Â","Ă","Ä","Å","Ï",
"Ö","Ř","OÞ","PÞ","ß",

"á","â","ã","ä","å","æ","ç","è","é","ê","ë","ì","í","î","ï",
"ð","ñ","ò","ó","ô","õ","ö","ř","ø","ù","ú","ÿ",

"LÑ","MÑ","OÑ","PÑ",
"i","j","É",
"×¢","×£","£Þ","×¦","¬","×µ","×I","×J","JÞ","×¦f","¬f","×R",  

"˘","I","Ł","J","¦","§","K",    
"¨","L","Ş","þ","¬","Ó","®",
"M","N","O","P","Ż",

"°","±","Q","ý","˛","ł",
"´","µ","R", "¶", "•", "¸",

"ą","S","»","Õ","¼","T","˝","U","V","¾","à","¿","Ŕ","Á","W",

"Aü","A","BĘ","B","C","D","EZ","Em","E|","E","F","G","H", 

"f","e","b","c","Æ","Ç","Č","Z","m","|","`","ű","ü","a","h","g",
"Ð","Ò","Ô","Ţ",

"q","r","s","t","u","v","w","x","y","z",

"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ॅा","ाे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे","ाें","ॅं","ंॅ")     // Remove typing mistakes in the original file

var array_two = new Array( '्र',

"","","ॐ","ऽ","।","॥","॰", 

"ल्ल","ङ्म","स्र","त्र","त्न","प्त",
"ङ्क","ङ्ख","ङ्ग","ङ्घ","ङ्क्त","ञ्च","क्च","ह्न","द्ब्र","ढ्ढ","छ्व",
"ह्य","ह्ण","ह्ल","ह्व","झ्र","ट्ट","ट्ठ","ह्म्","श्च","क्र",
"ख्र्","ख्न्","च्च्","ज्ज्",
"त्र्","क्ष्","ज्ञ्","ष्ट्व","ह्र",
"न्न्","त्त्","ड़","ढ़","श्र्",

"ष्ट","ष्ठ","श्ल","श्व","स्त्र","क्क","ड्ड","ड्ढ","क्व","स्र","्य","ञ्ज","द्ग","द्घ","द्द",
"द्ध","द्ब","द्भ","द्म","द्य","द्व","क्त","रु","रू","हृ","दृ","ठ्ठ",

"छ्र","ट्र","ड्र","ढ्र",
"्र","्न","्ल",
"क़्","ख़्","ख़्","ग़्","ज़्","फ़्","क़","ख़","ख़","ग़","ज़","फ़",

"क्","क","ख्","ख","ग्","घ्","ङ",  
"च्","छ","ज्","ज","ज़्","झ्","ञ्",
"ट","ठ","ड","ढ","ण्",

"त्","थ्","द","द","ध्","न्",
"प्","फ्","फ","ब्","भ्","म्",

"य्","र","ल्","ल","ळ्","ळ","व्","व","श्","श्","श","ष्","स्","ह्","ह",

"औ","अ","ई","इ","उ","ऊ","ऐ","ऐ","ऐ","ए","ऋ","ॠ","ऌ", 

"ा","ी","ु","ू","ु","ू","ृ","े","े","े","ै","ो","ौ","ं","ँ","ॅ",
"्","ँ","ं","़",

"०","१","२","३","४","५","६","७","८","९",

 
"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ॉ","ो",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें","ों","ँ","ँ")     // Remove typing mistakes in the original file 

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
// "d",
// "ि",
//
// "Ê",
// "र्" (reph) 
//**************************************************************************************

var array_one_length = array_one.length ;

var modified_substring = document.getElementById("unitext").value  ;

//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = document.getElementById("unitext").value.length ;

    var processed_text = '' ;  //blank

//**********************************************
//    alert("text size = "+text_size);
//**********************************************

    var sthiti1 = 0 ;  var sthiti2 = 0 ;  var chale_chalo = 1 ;
 
    var max_text_size = 6000;

    while ( chale_chalo == 1 ) 
    {
     sthiti1 = sthiti2 ; 

     if ( sthiti2 < ( text_size - max_text_size ) )  
     { 
      sthiti2 +=  max_text_size ;
      while (document.getElementById("unitext").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }
      
//   alert(" sthiti 1 = "+sthiti1); alert(" sthit 2 = "+sthiti2) 

     var modified_substring = document.getElementById("unitext").value.substring ( sthiti1, sthiti2 )  ;

     Replace_Symbols_4CGandhi_Unicode( );

    processed_text += modified_substring ;
     

//****************************************************************************************
//  Breaking part code over
//****************************************************************************************
//  processed_text = processed_text.replace( /mangal/g , "SUCHI-DEV-708 " ) ;   

    document.getElementById("unitext").value = processed_text  ;
   }


// --------------------------------------------------


function Replace_Symbols_4CGandhi_Unicode( )

{

//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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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


// alert(" modified substring2 = "+modified_substring)
//**********************************************************************************
// Codes for Special Glyphs
//**********************************************************************************
// Glyph1 : Ë (reph+anusvAr)
// Glyph2 : Í  (ि+reph)
// Glyph3 : Î ("िं") 
// Glyph4 : Ì (reph+ikAr+anusvAr "र्िं")
//**********************************************************************************
// Code for Glyph1 : Ë (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /Ë/g , "Êं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".

//**********************************************************************************
// Code for Glyph2 : Í  (ि+reph)
//**********************************************************************************
   modified_substring = modified_substring.replace( /Í/g , "र्d" ) ;  // at some places  Ì  is  used eg  in "धार्मिक".

// ****************************** 
var position_of_i = modified_substring.indexOf( "d" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "d" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /d/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Glyph3 : Î (ि+anusvAr)
// Glyph4 : Ì (reph+ikAr+anusvAr "र्िं")
//**********************************************************************************
modified_substring = modified_substring.replace( /Ì/g , "ÊÎ" ) ;  // at some places  Ì  is  used eg  in "धार्मिक".
modified_substring = modified_substring.replace( /Î/g , "da" ) ;  // at some places  Ì  is  used eg  in "धार्मिक".

var position_of_i = modified_substring.indexOf( "da" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_ip2 = modified_substring.charAt( position_of_i + 2 )
var charecter_to_be_replaced = "da" + charecter_next_to_ip2
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_ip2 + "िं" ) 
position_of_i = modified_substring.search( /da/ , position_of_i + 2 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ę" and putting 'half - r' at proper position for this.
set_of_matras = "ािीुूृेैोौं:ँॅ" 

modified_substring = '  ' + modified_substring ;  // to avoid error due to search index becoming negative.
var position_of_R = modified_substring.indexOf( "Ę" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05

if ( modified_substring.charAt( probable_position_of_half_r - 1 ) == '्' )
  { probable_position_of_half_r = probable_position_of_half_r - 2 ;
      if ( modified_substring.charAt( probable_position_of_half_r - 1 ) == '्' )
           probable_position_of_half_r = probable_position_of_half_r - 2 ; }

charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "Ę" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "Ę" ) ;

} // end of while-04

//**********punctuation marks ****************
// "k","l",
//  "‘","’",

modified_substring = modified_substring.replace( /k/g , "‘" )   ;  
modified_substring = modified_substring.replace( /l/g , "’" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of legacy_to_unicode function



//******************************************************************************



function ConvertUnicode_to_4CGandhi()
{
var array_one = new Array(
"क़्","ख़्","ग़्","ज़्","ड़्","ढ़्","फ़्","क़","ख़","ग़","ज़","ड़","ढ़","फ़", //two-byte nuqta characters

"ड़","ढ़",   // "ड़ि","ढ़ि","क़ि","ख़ि","ग़ि","ज़ि","फ़ि",

"ॐ","ऽ","।","॥","॰", 

"ल्ल","ङ्म","स्र","त्न","प्त",
"ङ्क","ङ्ख","ङ्ग","ङ्घ","ङ्क्त","ञ्च","क्च","ह्न","द्ब्र","ढ्ढ","छ्व",
"ह्य","ह्ण","ह्ल","ह्व","झ्र","ट्ट","ट्ठ","ह्म्","ह्म","श्च","फ्र","क्र", // "क्र",
"ख्र्","ख्न्","च्च्","ज्ज्",
"त्र्","त्र","क्ष्","क्ष","ज्ञ्","ज्ञ","ष्ट्व","ह्र",  //"श्र्य","त्र्य",
"न्न्","त्त्","त्त","श्र्","श्र","शृ",


"ष्ट","ष्ठ","श्ल","श्व","स्त्र","क्क","ड्ड","ड्ढ","क्व","स्र","ञ्ज","द्ग","द्घ","द्द",

"छ्र","ट्र","ड्र","ढ्र","्र",

"द्ध","द्ब","द्भ","द्म","द्य","द्व","क्त","रु","रू","हृ","दृ","ठ्ठ",

"कु","कू","कृ","के","कै","कँ","कं",
"फु","फू","फे","फै","फँ","फं",

"क़्","ख़्","ख़्","ग़्","ज़्","फ़्","क़","ख़","ख़","ग़","ज़","फ़",

"क्","ख्","ग्","घ्",
"क","ख","ग","घ","ङ",
  
"च्","ज्","झ्","ञ्",
"च","छ","ज","झ","ञ",

"ट","ठ","ड","ढ","ण्","ण",

"त्","थ्","ध्","न्",
"त","थ","द","ध","न",

"प्","फ्","ब्","भ्","म्",
"प","फ","ब","भ","म",

"य्","ल्","ळ्","व्",
"य","र","ल","ळ","व",

"श्","ष्","स्","ह्",
"श","ष","स","ह",

"्य","्न","्ल",  // "्रु","्रू",

"औ","ओ","ऑ","आ","अ","ई","इ","उ","ऊ","ऐ","ए","ऋ","ॠ","ऌ", 

"ॉ","ा","ी","ु","ू","ृ","े","ै","ो","ौ","ं","ँ","ः","ॅ",   //"ु","ू","े","े",
"्","ँ","ं","़",

"०","१","२","३","४","५","६","७","८","९"  )

var array_two = new Array(

"क़्","ख़्","ग़्","ज़्","ड़्","ढ़्","फ़्","क़","ख़","ग़","ज़","ड़","ढ़","फ़",  //one-byte nuqta characters

"OÞX","PÞX",  // "dOÞX","dPÞX","d×I","d×J","d×¦f","d¬f","d×R",

"Û","Ú","Ü","Ý","Ù",

"n","o","p","}","~",
"‚","ƒ","„","…","†","‡","ˆY","‰","Š","‹","Œ",
"‘","’","“","”","–","˜","™","š","šf","›","RiY","IiY", // "œY",
"¤","¥","©","«",
"Â","{","Ã","Ãf","Ä","Äf","Å","Ï",  // "ß¹f","Â¹f",
"Ö","Ø","Øf","ß","ßf","àÈ",


"á","â","ã","ä","å","æY","ç","è","é","ê","ì","í","î","ï",

"LÑ","MÑ","OÑ","PÑ","i",

"ð","ñ","ò","ó","ô","õ","öY","÷Y","øY","ù","ú","ÿ",

"IbY","IcY","IÈY","IZY","I`Y","IhY","IaY",
"RbY","RcY","RZY","R`Y","RhY","RaY",

"×¢","×£","£Þ","×¦","¬","×µ","×I","×J","JÞ","×¦f","¬f","×R",  

"¢","£","¦","§",    
"IY","J","¦f","§f","K",    

"¨","ª","¬","Ó",
"¨f","L","þ","Óf","®f",

"MX","NX","OX","PX","¯","¯f",

"°","±","²","³",
"°f","±f","Q","²f","³f",

"´","µ","¶","•","¸",
"´f","RY","¶f","•f","¸f",

"¹","»","¼","½",
"¹f","SX","ÕX","T","U",

"V","¿","À","Á",
"Vf","¿f","Àf","WX",

"ë","j","É",    //"fib","fic",

"Aü","Aû","Afg","Af","A","BÊ","B","CX","DY","EZ","E","FY","GY","H", 

"fg","f","e","b","c","È","Z","`","û","ü","a","h",":","g",   //"Æ","Ç","m","|",
"Ð","Ò","Ô","×",

"q","r","s","t","u","v","w","x","y","z" )


//**************************************************************************************
//  To be edited above this line
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
// "d",
// "ि",
//
// "Ę",
// "र्" (reph) 
//**************************************************************************************

var array_one_length = array_one.length ;
var array_two_length = array_two.length ;

if ( array_one_length == array_two_length ) 
  document.getElementById("output").value = "Both the arrays are of equal length"  ;  
  else document.getElementById("output").value = "Both the arrays are NOT of equal length"  ;  

  document.getElementById("output").value = "You have chosen SIMPLE TEXT in Unicode to convert into 4CGandhi. Conversion in progress.."  ;  

var modified_substring = document.getElementById("unitext").value  ;

Replace_Symbols_Unicode_4CGandhi( );
  //  alert(" modified substring = "+modified_substring)

    var processed_text = modified_substring ;

 //   alert(" modified substring2 = "+modified_substring)

    document.getElementById("output").value = processed_text  ;

	

//**************************************************
//--------------------------------------------------
//**************************************************



function Replace_Symbols_Unicode_4CGandhi( )
   {
// "d",
// "ि",
//
// "Ę",
// "र्" (reph) 


    // if string to be converted is non-blank then no need of any processing.
    if (modified_substring != "" )  
       {
        // code for replacing "ि" (chhotee ee kii maatraa) with "d" 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 + "ि" ,  "d" + 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 + "d", "d" + 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
		   
 
   //************************************************************     
        // Eliminating "र्" and putting  "Ę"   at proper position for this.
		
// before searching and replacing half-R,  replace 'tr' and 'shr' so that they  do not intrude with half-R search-and-replace activity.				
		modified_substring = modified_substring.replace( /श्र्/g  , 'ß' ) ;
		modified_substring = modified_substring.replace( /त्र्/g  , 'Â' ) ;
		

       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( "र्" ) ;
        while ( position_of_half_R > 0  )  // while-04
           {
            // "र्"  is two bytes long
			 if ( modified_substring.charAt( position_of_half_R + 3 ) != '्' ) 
                  var probable_position_of_Z = position_of_half_R + 3    
			
			    else { if ( modified_substring.charAt( position_of_half_R + 5 ) != '्' ) 
			              probable_position_of_Z = position_of_half_R + 5
                         else probable_position_of_Z = position_of_half_R + 7 ;				  
					  }
			
            var character_right_to_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z + 1 )

            // trying to find non-maatra position right to probable_position_of_Z .

            while ( set_of_matras.indexOf( character_right_to_probable_position_of_Z ) != -1 )  
               {
                probable_position_of_Z = probable_position_of_Z + 1 ;
                character_right_to_probable_position_of_Z = modified_substring.charAt( probable_position_of_Z + 1 ) ;
               } // end of while-05
			   
			  
            string_to_be_replaced = modified_substring.substr ( position_of_half_R + 2 , ( probable_position_of_Z - position_of_half_R - 2 ))  ;
            modified_substring = modified_substring.replace( "र्" + string_to_be_replaced  ,  string_to_be_replaced + "Ê" ) ;
            position_of_half_R = modified_substring.indexOf( "र्" ) ;
           } // end of while-04


        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
//***********************************************************************
// shift the ikAr mAtrAs of nuqta characters in 4CGandhi
//***********************************************************************
         modified_substring = modified_substring.replace( /OXd×/g , "dOÞX" ) ;
         modified_substring = modified_substring.replace( /PXd×/g , "dPÞX" ) ;
         modified_substring = modified_substring.replace( /IYd×/g , "d×IY" ) ;
         modified_substring = modified_substring.replace( /Jd×/g , "d×J" ) ;
         modified_substring = modified_substring.replace( /¦fd×/g , "d×¦f" ) ;
         modified_substring = modified_substring.replace( /þd×/g , "dþÞ" ) ;
         modified_substring = modified_substring.replace( /RYd×/g , "d×RY" ) ;


        } // end of IF  statement  meant to  supress processing of  blank  string.

    } // end of the function  Replace_Symbols( )

  } // end of legacy_to_unicode  function

//+++++++++++++++++++++++++++++++END OF 4CGandhi_Unicode_4CGandhi+++++++//
//+++++++++++++++++START OF SHREEDEV0702_UNICODE_SHREEDEV0702+++++++++//
function convertShreedev702_to_unicode()
{

var array_one = new Array(">", "$","[", "p","“","”",                  //06
"µH","™","˜","µJ","µO","µS","µT","µ\\",                                //08
"ª", "£", "¤", "u", "v",      "}", "]",						//07
"›","@","&","\"","'",                        		                  //05
"ú","j","k","l","Ì","Í","Î",                        		            //07
"®","¯","é","ê",                        		                        //04

"#","‚","ƒ","„","†", "‡","ˆ","‰",                        		      //08 
"’","“","”","•","¬","–","—","œ",                        		      //08
"³", "¶",  "¸",  "¹","º","¼", "Ã", "¾","Å","Æ","Ç","È","É",             //13
"Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Þ","à","á","ï","ð",    //17
"ò","ó",   "õ","ö","÷","ø",    "ü","ý",                           	//08
"ç", "Œ", "´",  "«",                       		                  //04

"Š","»","½", "¿","H","I","J","K","L",                                   //09
"À","Á","Â","Ä","M","N","O","P",                                        //08
"Q","R","S","T","Ê","U",                        		            //06
"Ë", "Ï", "Ü","Ý","V","W","X","Y","Z",                       	      //09
"ß","â","ã","ä","å","n","\\","~", "^","_",                        	//10

"æ", "ë","ì","í","î", "ù",  "û", "ñ","ô",                               //09
"`","a","b","c","d","e","f","g","h","i",                        		//10

"Am¡","Amo","Am°","Am","A","B©","B","C","D","F","G","Eo","E",           //13
                        		           

"m", "r","s", "t","w","x","y","z","¥","¦","|","o","¡","¢","…","§","¨","µ", //18
"þ","ÿ","°","±","²",                                                       //05

"0","1","2","3","4","5","6","7","8","9",

"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ॅा","ाे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे","ाें","ॅं","ंॅ"," ः","ंू")     // Remove typing mistakes in the original file

var array_two = new Array("","","{","{","\"","'",
"क़","ख़्","ख़","ग़","ज़","ड़","ढ़","फ़", // one-byte varnas
"ं©",  "ै©","ैं©","ी©","ीं©", "े©", "ें©",
"ॐ","ऽ","।","‘","’",
"क्ष्","क्ष","ज्ञ","श्र","त्र","त्र्","त्त्",
"्रु","्रू","रु","रू",

"ञ्च्","ज्ज्","च्च","ल्ल","ह्ण","ह्ल","ह्व","्व",
"ङ्क","ङ्ख","ङ्ग","ङ्घ","ङ्क्ष","ह्न","ड्ढ","श्व",
"्न", "ङ्म", "क्क","क्व","क्त","ख्र", "झ्र",  "ग्न", "ट्ट","ट्ठ","ठ्ठ","ड्ड","ड्ढ",
"द्र","दृ","द्ग","द्घ","द्द","द्ध","द्न","द्ब","द्भ","द्म","द्य","द्व","न्न","प्र","प्त","ष्ट","ष्ठ",
"स्र","स्त्र",    "ह्र","हृ","ह्म","ह्य",   "श्च","श्न", 
"्य", "्र","्र","्र",

"क्","ख्", "ग्", "घ्","क","ख","ग","घ","ङ",
"च्","ज्","झ्","ञ्","च","छ","ज","झ",
"ट","ठ","ड","ढ","ण्","ण",
"त्","थ्", "ध्","न्","त","थ","द","ध","न",
"प्","फ्","ब्","भ्","म्","प","फ","ब","भ","म",

"य्", "ल्","व्","श्","ष्", "ळ्", "श्", "स्","ह्", 
"य","र","ल","ल","व","श","ष","स","ह","ळ",

"औ","ओ","ऑ","आ","अ","ई","इ","उ","ऊ","ऋ","ॠ","ऐ","ए",   

"ा", "ी","ी", "ीं", "ु","ु","ू","ू", "ृ","ॄ", "ें", "े", "ै","ैं", "ः", "ं","ं","़",
"ु","ू","ॅ","ँ","्",

"०","१","२","३","४","५","६","७","८","९",

"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ॉ","ो",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें","ों","ँ","ँ"," :","ूं")     // Remove typing mistakes in the original file 

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
//   "{",
//   "ि",
//
//   "©",
//   "र्" (reph)
// 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols_Shreedev702_Unicode( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").value = processed_text  ;

// --------------------------------------------------


function Replace_Symbols_Shreedev702_Unicode( )

{

//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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************
var position_of_i = modified_substring.indexOf( "{" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "{" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /{/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ô" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "©" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "©" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "©" ) ;

} // end of while-04

//**********punctuation marks ****************
//    "¡","£","¤","¥","²","³","´","µ","¹","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","Ê","Ñ","Ò","Õ",
// "{","}","[","]","!","(",")","*","-","/",":",";","<","=",">","?","@","|",",","!","\\","√","-",

//modified_substring = modified_substring.replace( /¡/g , "{" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function


//*******************************************************************************
function convertUnicode_to_Shreedev0702()
{
var array_one = new Array("–",
"के","ङे","छे","टे","ठे","डे","ढे","ळे","हे","ऊँ",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़", // one-byte varnas               //07
//"ं©",  "ै©","ैं©","ी©","ीं©", "े©", "ें©",
"ॐ","ऽ","।","‘","’",                                          //05
"क्ष्","क्ष","ज्ञ","श्र","त्र","त्र्","त्त","त्त्",                                   //07
"्रु","्रू","रु","रू",                                           //04

"ञ्च्","ज्ज्","च्च","ल्ल","ह्ण","ह्ल","ह्व", //"्व",                           //08
"ङ्क","ङ्ख","ङ्ग","ङ्घ","ङ्क्ष","ह्न","ड्ढ","श्व",                          //08
"ङ्म", "क्क","क्व","क्त","ख्र", "झ्र",  "ग्न", "ट्ट","ट्ठ","ठ्ठ","ड्ड","ड्ढ",  //13 "्न",
"द्र","दृ","द्ग","द्घ","द्द","द्ध","द्न","द्ब","द्भ","द्म","द्य","द्व","न्न","प्र","प्त","ष्ट","ष्ठ",     //17
"स्र","स्त्र",    "ह्र","हृ","ह्म","ह्य",   "श्च","श्न",                         //08

"छ्र","ट्र","ड्र","ढ्र",                                             //04
 "्र",                                                //02

"क्","ख्", "ग्", "घ्","क","ख","ग","घ","ङ",                           //09
"च्","ज्","झ्","ञ्","च","छ","ज","झ",                               //08
"ट","ठ","ड","ढ","ण्","ण",                                       //06
"त्","थ्", "ध्","न्","त","थ","द","ध","न",                            //09
"प्","फ्","ब्","भ्","म्","प","फ","ब","भ","म",                         //10

"य्", "ल्","व्","श्","ष्", "ळ्", "श्", "स्","ह्",                         //09
"य","र","ल","ल","व","श","ष","स","ह","ळ",                          //10
"्य",
"औ","ओ","ऑ","आ","अ","ई","इ","उ","ऊ","ऋ","ॠ","ऐ","ए",              //13

"ौ","ो","ॉ","ा","ी","ु","ू","ृ","ॄ","े","ै","ँ","ं","ः","्","ॅ","़",    //17

"०","१","२","३","४","५","६","७","८","९")

var array_two = new Array("-",//"$","[", "p",                                //03
"Ho$","Lo>","No>","Qo>","Ro>","So>","To>","io>","ho>","D±$",
"µH$","™","µJ","µO","µS>","µT>","µ\\>",                                     //07
//"ª",   "£","¤", "u", "v",      "}", "]",					//07
"›","@","&","\"","'",                        		                  //05
"ú","j","k","l","Ì","Í","Îm","Î",                       		      //07
"®","¯","é","ê",                        		                        //04

"#","‚","ƒ","„","†", "‡","ˆ",  // "‰",                      		      //08 
"’>","“","”","•","¬","–","—","œ",                        		      //08
"¶",  "¸$",  "¹","º$","¼", "Ã", "¾","Å","Æ","Ç","È","É",             //13 "³",
"Ð","Ñ","Ò","Ó","Ô","Õ","Ö","×","Ø","Ù","Ú","Û","Þ","à","á","ï","ð",    //17
"ò","ó",   "õ","ö","÷","ø",    "ü","ý",                           	//08

"N—>","Q—>","S—>","T—>",                                                    //04
  "«",                       		                              //02

"Š","»","½", "¿","H$","I","J","K","L>",                                   //09
"À","Á","Â","Ä","M","N>","O","P",                                        //08
"Q>","R>","S>","T>","Ê","U",                        		            //06
"Ë", "Ï", "Ü","Ý","V","W","X","Y","Z",                       	      //09
"ß","â","ã","ä","å","n","\\$","~", "^","_",                        	//10

"æ", "ë","ì","í","î", "ù",  "û", "ñ","ô",                               //09
"`","a","b","c","d","e","f","g","h>","i>",                        		//10

"ç",

"Am¡","Amo","Am°","Am","A","B©","B","C","D$","F","G","Eo","E",           //13   

"m¡","mo","m°","m","r","w","y","¥","¦","o","¡","±","§","…","²","°","µ",  //17

"0","1","2","3","4","5","6","7","8","9")
  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
//   "{",
//   "ि",
//
//   "©",
//   "र्" (reph)
// 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unicode").value  ;

    Replace_Symbols_Unicode_Shreedev702( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").value = processed_text  ;


//**************************************************

function Replace_Symbols_Unicode_Shreedev702( )
   {

    // 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 ( /क़/ , "क़" )  ; 
// 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 "{"  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 + "ि" ,  "{" + 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 + "{", "{" + 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
   //************************************************************     
        // 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.
  
 //     modified_substring = modified_substring.replace ( /-/g , "¹" )  ; 
 //     modified_substring = modified_substring.replace ( /श्र्/g , "E" )  ; 
 //     modified_substring = modified_substring.replace ( /त्र्य/g , "~\\ya" )  ; 

       var space = " "
       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 + "©" ) ;

//     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 ( /-ao/g , "ao-" ) 
 //      modified_substring = modified_substring.replace ( /-a/g , "a-" )  
 //      modified_substring = modified_substring.replace ( /-I/g , "I-" )  
 //      modified_substring = modified_substring.replace ( /\ -/g , "\-" )
 //      modified_substring = modified_substring.replace ( /ki,/g , "ik," ) 
 //      modified_substring = modified_substring.replace ( /Ki,/g , "iÓ" ) 
 //      modified_substring = modified_substring.replace ( /gai,/g , "iga," ) 
 //      modified_substring = modified_substring.replace ( /fi,/g , "iÔ" ) 
 //      modified_substring = modified_substring.replace ( /Di,/g , "iD," ) 
 //      modified_substring = modified_substring.replace ( /Zi,/g , "iZ," ) 
 //      modified_substring = modified_substring.replace ( /jai,/g , "ija," ) 
 //      modified_substring = modified_substring.replace ( /nai,/g , "ina," ) 
 //      modified_substring = modified_substring.replace ( /ri,/g , "ir," ) 
 //      modified_substring = modified_substring.replace ( /Li,/g , "iL," ) 


    } // end of the function  Replace_Symbols( )

  } // end of convert_to_Shusha function

//+++++++++++++++++END OF SHREEDEV_UNICODE_SHREEDEV++++++++++++++++++++//
//+++++++++++++++++START OF CHANAKYA_UNICODE_CHANAKYA+++++++++++++++++//
function convertChanakya_to_unicode()
{

var array_one = new Array(

"¤","U",

// correct anusvAr+ekAr, ekAr+nuqta to the reverse order
"¢ð","´ð","ð¸",
   
"¥æò","¸",
"¸•", "¸¹", "¸»", "¸Á","¸Ç", "¸É", "¸È","¸Ø","¸Ú","¸Ù",
 
"A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","T","V","W","X","Y",

"`","a","b","d","e","f","g","h","i","j","k","l","m","n","p","q","r","s","t","u",

"žæ","ž","#","%","@",
"„","¦","¨","¯","µ","º",

"Cþ","q","Ê","u","g",    
"Ÿæ","Åþ","Çþ","Éþ", 
"^","h","Ð","ý","þ",

 
"¥ô","¥æð","¥õ","¥æñ","¥æ","¥","§Z","§ü","§","©","ª","«","¬","¬","°ð","°",

"€","•","","¹","‚","»","ƒæ","ƒ","¾", 
"“","‘","¿","À","”","…","’","Á","Ûæ","Û","†æ","†",

"Å","Æ","Ç","É","‡æ","‡",
"ˆ","Ì","‰","Í","Î","¼","Š","Ï","óæ","ó","‹æ","Ù","‹",

"Œ","Â","","È","Ž","Õ","","Ö","","×",
"Ä","Ø","Ú","Ë","Ü","¶","Ý","Ã","ß",
"àæ","³æ","o","³","à","c","á","S","â","ã","±",
"ÿæ","ÿ","˜æ","˜","™æ","™","üð´",
 
"æò","æñ","æ","è","é","ê","ä","å","ë","ì","í","Ô","ñ","ô","õ",
"¢","´","¡","Ñ","¸","ò","ù","÷","ð",
"Z",

"0","1","2","3","4","5","6","7","8","9",
"®","v","w","x","y","z","{","|","}","~",
"्ो","्ौ","्ाे", "्ाा","ाे","ाे","ाै","्ा","ंु","ओे","ोे","ाे","ईंं" )   


var array_two = new Array(

"","",

// correct anusvAr+ekAr, ekAr+nuqta to the reverse order
"ð¢","ð´","¸ð",

"ऑ","फ़्", 
"क़","ख़","ग़","ज़","ड़","ढ़","फ़","य़","ऱ","ऩ",

"्र","क्च","ष्ट","ष्ठ","श्व","स्न","त्र","॥","ढ्ढ","छ्व","्य","रु","रू",
"हृ","ह्र","क्क","क्त","क्र","ञ्ज","ङ्क","ङ्ख","ङ्ग","ङ्घ",
"क्व","ड्ड","ड्ढ","स्र","द्ग","द्घ","द्द","द्ध","द्ब","द्भ","द्म","द्य","द्व","ठ्ठ","श्च","ह्न","ह्म्","ह्य","ह्ल","ह्व",
 
"त्त","त्त्","प्त","त्न","ञ्च",
"ल्ल","ष्ट्व","ङ्क्ष","ख्न","द्ब्र","ख्र",

"ष्ट्र","ह्न","ज़्","ह्व","द्द",  
"श्र","ट्र","ड्र","ढ्र",
"ट्ट","द्ध","।","्र","्र",
 
"ओ","ओ","औ","औ","आ","अ","ईं","ई","इ","उ","ऊ","ऋ","ॠ","ऌ","ऐ","ए",

"क्", "क","ख्","ख","ग्","ग","घ","घ्","ङ",
"च्च्","च्","च","छ","ज्ज्","ज्","ज्","ज","झ","झ्","ञ","ञ्",
 
"ट","ठ","ड","ढ","ण","ण्",
"त्","त","थ्","थ","द","द","ध्","ध","न्न","न्न्","न","न","न्",

"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",
"य्","य","र","ल्","ल","ल","ळ","व्","व",
"श","श","श","श्","श्","ष्","ष","स्","स","ह","ह्",
"क्ष","क्ष्","त्र","त्र्","ज्ञ","ज्ञ्","ðZ",

"ॉ","ौ","ा","ी","ु","ू","ु","ू","ृ","ॄ","ॢ","े","ै","ो","ौ",
"ं","ं","ँ",":","़", "ॅ","ऽ","्","े",
"ंü",

"०","१","२","३","४","५","६","७","८","९",
"0","1","2","3","4","5","6","7","8","9",

"े", "ै", "े","ा","ो","ो","ौ","","ुं","ओ","ो","ो","ईं")   

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
// "र्" (reph) 
// "ü" 

// "ि"  
// "ç" 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols_Chanakya_to_unicode( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").value = processed_text  ;

// --------------------------------------------------


function Replace_Symbols_Chanakya_to_unicode( )

{

//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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************
var position_of_i = modified_substring.indexOf( "ç" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "ç" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /ç/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ô" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "ü" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "ü" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "ü" ) ;

} // end of while-04

//**********punctuation marks ****************
//    "¡","£","¤","¥","²","³","´","µ","¹","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","Ê","Ñ","Ò","Õ",
// "{","}","[","]","!","(",")","*","-","/",":",";","<","=",">","?","@","|",",","!","\\","√","-",

modified_substring = modified_substring.replace( /Ò/g , "‘" )   ;  
modified_substring = modified_substring.replace( /Ó/g , "’" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function


//*******************************************************************************
function convertUnicode_to_chanakya()
{
var array_one = new Array(
"ज़्","फ़्","क़","ख़","ग़","ज़","ड़","ढ़","फ़","य़","ऱ","ऩ",    // two-byte nukta varNas
"‘","’","“","”","–","ं","ऑ",

"त्र्","श्र्",
"क्र","ग्र","घ्र",
"छ्र","ट्र","ड्र","ढ्र",
"त्र","द्र","ध्र",
"प्र","फ्र","ब्र","भ्र","म्र",
"व्र","श्र","स्र","ह्र",
"ष्ट्र", "रु","रू",

"क्ष्","क्ष","ज्ञ","् ","्,","्;",
                     
"क़","ख़","ग़","ज़्","ज़","ड़","ढ़","फ़्","फ़","य़","ऱ","ऩ",      // one-byte nukta varNas

"क्च","ष्ट","ष्ठ","श्व","॥","ढ्ढ","छ्व", //"स्न", creates problem in कार्त्स्न्य
"हृ","क्क","क्त","ञ्ज","ङ्क","ङ्ख","ङ्ग","ङ्घ","ट्ट","ट्ठ",

"क्व","ड्ड","ड्ढ","द्ग","द्घ","द्द","द्ध","द्ब","द्भ","द्म","द्य","द्व","ठ्ठ","श्च","ह्न","ह्म","ह्म्","ह्य","ह्ल","ह्व",
 
"त्त","त्त्","प्त","ञ्च",  //"त्न",
"ल्ल","ष्ट्व","ङ्क्ष",  //"ख्न","द्ब्र","ख्र",

"ह्न","ह्व","द्द",  
"।","्र",
"शृ","शॄ","कॢ","ह्ण",

"ओ","औ","आ","अ","ईं","ई","इ","उ","ऊ","ऋ","ॠ","ऌ","ऐ","ए",

"के","कै","फे","फै",  //"कं","फं",

"क्","क", "ख्","ख","ग्","ग","घ्","घ","ङ",
"च्च्","च्","च","छ","ज्ज्","ज्","ज","झ्","झ","ञ्","ञ",

"ट","ठ","ड","ढ","ण्","ण",
"त्","त","थ्","थ","द","ध्","ध","न्न्","न्न","न्","न",

"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",
"य्","य","र","ल्","ल","ळ","व्","व",
"श्","श","ष्","ष","स्","स","ह्","ह",
"्य","x",

"ॉ","ा","ी","ु","ू","ृ","ॄ","ॢ","े","ै","ो","ौ",
"ं","ं","ँ","ः","़", "ॅ","ऽ","्",

"०","१","२","३","४","५","६","७","८","९",
"0","1","2","3","4","5","6","7","8","9")

var array_two = new Array(
"ज़्","फ़्","क़","ख़","ग़","ज़","ड़","ढ़","फ़","य़","ऱ","ऩ",      // one-byte nukta varNas
"Ò","Ó","\"","\"","-","´","¥æò",

"˜","Ÿ",
"R¤","»ý","ƒæý",
"Àþ","Åþ","Çþ","Éþ",
"˜æ","Îý","Ïý",
"Âý","È¤ý","Õý","Öý","×ý",
"ßý","Ÿæ","d","O",
"cÅþ","L¤","M¤",

"ÿ","ÿæ","™æ","÷ ","÷,","÷;",
"•¸¤", "¹¸", "»¸", "Ê", "Á¸","Ç¸", "É¸", "¸U","È¸¤","Ø¸","Ú¸","Ù¸", 
// "•¸¤", "¹¸", "»¸", "Á¸","Ç¸", "É¸", "¸U","È¸¤","Ø¸","Ú¸","Ù¸", 

"B¤","C","D","E","H","I","J", //"F",creates problem in कार्त्स्न्य
"N","P¤","Q¤","T","V","W","X","Y","^","_",

"`¤","a","b","e","f","g","h","i","j","k","l","m","n","p","q","ræ","r","s","t","u",

"žæ","ž","#","@", //"%",
"„","¦","¨",      // "¯","µ","º",

"q","u","g",    
"Ð","ý",
"oë","oì","•í","ö",

"¥ô","¥õ","¥æ","¥","§Z","§ü","§","©","ª¤","«¤","¬¤","¬","°ð","°",

"•Ô¤","•ñ¤","ÈÔ¤","Èñ¤",   // "•´¤","È´¤",

"€U","•¤","","¹","‚","»","ƒ","ƒæ","¾", 
"“","‘","¿","À","”","’","Á","Û","Ûæ","†","†æ",

"ÅU","Æ","Ç","É","‡","‡æ",
"ˆ","Ì","‰","Í","Î","Š","Ï","ó","óæ","‹","Ù",

"Œ","Â","U","È¤","Ž","Õ","","Ö","","×",
"Ä","Ø","ÚU","Ë","Ü","Ý","Ã","ß",
"à","àæ","c","á","S","â","±","ã",
"K","&",
 
"æò","æ","è","é","ê","ë","ì","í","ð","ñ","ô","õ",
"¢","´","¡","Ñ","¸","ò","ù","÷",

"0","1","2","3","4","5","6","7","8","9",
"®","v","w","x","y","z","{","|","}","~")
  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// The following two characters are to be replaced through proper checking of locations:

// "र्" (reph) 
// "ü" )

// "ि"  
// "ç" )


    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols_Unicode_to_chanakya( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").value = processed_text  ;


//**************************************************

function Replace_Symbols_Unicode_to_chanakya( )
   {

    // 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 ( /क़/ , "क़" )  ; 
// 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 "i"  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 + "ि" ,  "ç" + 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 + "ç", "ç" + 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.
  
//    modified_substring = modified_substring.replace ( /-/g , "¹" )  ; 
      modified_substring = modified_substring.replace ( /श्र्/g , "Ÿ" )  ; 
      modified_substring = modified_substring.replace ( /त्र्य/g , "˜Ø" )  ; 

       var space = " "
       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
      {  
//       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
   } // 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 + "ü" ) ;

//     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 ( /üè/g , "èü" ) 
       modified_substring = modified_substring.replace ( /üô/g , "ôü" ) 
       modified_substring = modified_substring.replace ( /üæ/g , "æü" ) 
       modified_substring = modified_substring.replace ( /ü´/g , "Z" ) 
       modified_substring = modified_substring.replace ( /÷ ü/g , "÷ü" ) 

   //    modified_substring = modified_substring.replace ( /ki,/g , "ik," ) 
   //    modified_substring = modified_substring.replace ( /Ki,/g , "iÓ" ) 
   //    modified_substring = modified_substring.replace ( /gai,/g , "iga," ) 
   //    modified_substring = modified_substring.replace ( /jai,/g , "ija," ) 
       modified_substring = modified_substring.replace ( /Çç¸/g , "çÇ¸" ) 
       modified_substring = modified_substring.replace ( /Éç¸/g , "çÉ¸" ) 
       modified_substring = modified_substring.replace ( /È¤ç¸/g , "çÈ¸¤" ) 

    } // end of the function  Replace_Symbols( )

  } // end of convert_to_chanakya function



//++++++END OF CHANAKYA_UNICODE_CHANAKYA+++++++//
//+++++START OF PRAKASH_UNICODE_PRAKASH++++++//
function convertPrakash_to_unicode()
{

var array_one = new Array("ef","òeâ","eR","Dee@","X","x","Z","z","eA","ea","Ë","e|","eE","eR","eé",
"›eâ","kesâ","ke=â","kegâ","Ìkeâ","ÌHeâ","Ìpe","ÌKe","ÌÙe","Ìie","Heâ","heâ","Heä","heä",
"Ìkeä","ÌK",
"Ô","~","$e+",
"Í","Î",
"Œe","Œ","œe","œ","®","™","¤",

"ß","$","«","›","¿","Ö","Ø","Ü","ã","ø","õ", 
"#","%","V","„","…","‰","‹","“","”","¢","£","¥","§","©","ª",
"°","º","»","À","Á","Â","Ã","Ä","Å","Æ","È","É","Ñ","Õ",

"æ","ñ","ò","ó","ô","ö","ù","ú","û","ÿ",

"Ì[","Ì{",

">","Ÿ","^","Ç","ü","ê",

"De","F&","F","G","è","S","T",

"keä","keâ","¡","K","i","I","*",       
"Û","Ú","p","P","_",

"š","\"","[","{","C",
"l","L","o","O","v",
"h","H","y","Y","c",         // "heä","heâ",

"Ù","j","u","}","à","k","J","U","M","ç","ë","<","m","å","n",

"er","e","¦","¶","ƒ","†","‡","á","ì","í","î",
"g","Ï","t","Ò","=","ï","s","w","b","B","Š","d","]","Ì","@","Ó","Ê",
"Q","W",

"0","1","2","3","4","5","6","7","8","9",

"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ॅा","ाे","एे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे","ाें","ॅं","ंॅ"," ः","ंू")     // Remove typing mistakes in the original file

var array_two = new Array("µ","क्त","ीं","ऑ","ें&","े&","ैं&","ै&","ीं&","ी&","ं&","&ि","िं","िं","िं",
"क्र","के","कृ","कु","क़","फ़","ज़","ख़","य़","ग़","फ","फ","फ्","फ्",
"क़्","ख़्",
"ॐ","।","ऋ",
"्रू","्रु",
"स्त्र","स्त्र्","स्र","स्र्","रु","रू","रू",

"श्र्","त्र्","ग्र्","व्र्","ज्र्","ह्न","प्र्","ह्र","झ्र्","प्र्","द्र",
"क्ष्","ज्ञ्","न्न्","ष्ट","ष्ठ","ष्ठ","ङ्घ","ङ्ख","ङ्ग","ह्य्","ह्व","ह्ल","श्च्","द्म्","ट्ठ",
"ष्ट","ड्ढ","ङ्क","ञ्ज्","ङ्ग","दृ","ञ्च्","व्न्","द्य्","द्भ","ङ्ख","द्व","ढ्ढ","श्व्",
"द्ध","ड्ड","त्त्","ट्ट","द्ब","द्द","हृ","ठ्ठ","द्ग","ह्म्",

"ड़","ढ़",
"्न","्य्","्र","्र","्र","्ल", 


"अ","ई","इ","उ","ऌ","ए","ऊ",

"क्","क","ख्","ख्","ग्","घ्","ङ",
"च्","छ","ज्","झ्","ञ्",

"ट","ठ","ड","ढ","ण्", 
"त्","थ्","द","ध्","न्",
"प्","प्","ब्","भ्","म्",    // "फ्","फ",

"य्","र","ल्","ल","ळ्","व्","व्","ळ","श्","श्","श्","ष्","स्","ह्","ह", 

"ी","ा","ा","ा","ा","ा","ा","ा","ा","ा","ा",
"ु","ु","ू","ू","ृ","ॢ","े","ै","ं","ँ","ः","्","़","़","ॅ","ऽ","॰",
"ैं","ें",

"०","१","२","३","४","५","६","७","८","९",

"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ॉ","ो","ऐ",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें","ों","ँ","ँ"," :","ूं")     // Remove typing mistakes in the original file 

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//******************************************************
//  Special glyphs
//******************************************************
//  "X",  "x", "Z",  "z", "eA", "ea", "Ë",  
//  "र्ें", "र्े", "र्ैं", "र्ै",  "र्ीं", "र्ी",  "र्ं",   
//  
//  "e\\", "e|", "eE", "eR", "eé",
//  "र्िं", "र्ि",  "िं",  "िं", "िं",
//******************************************************
//   ikAr and reph
//******************************************************
//   "ef","eq",
//   "ि","ि",
//
//   "&","N",
// "reph","reph (Marathi)",
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************

var position_of_i = modified_substring.indexOf( "µ" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "µ" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /µ/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ô" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "&" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "&" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "&" ) ;

} // end of while-04

//**********punctuation marks ****************
//    "¡","£","¤","¥","²","³","´","µ","¹","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","Ê","Ñ","Ò","Õ",
// "{","}","[","]","!","(",")","*","-","/",":",";","<","=",">","?","@","|",",","!","\\","√","-",
//
//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 , "?" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function


//*******************************************************************************
function convertUnicode_to_Prakash()
{
var array_one = new Array("“","”","\"","् ",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  // two-byte varnas                      //07
"ऑ","क्त","क्र","के","कृ","कु","क़","फ़","ज़","ख़","य़","ग़","फ","फ","फ्","फ्",           //16
"क़्","ख़्",                     						    //02
"ॐ","।","ऋ",                    						    //03
"स्त्र","स्त्र्","स्र","स्र्",                  				    //07

"क्षि","त्रि","ज्ञि","श्रि",                     					    //04
"श्र","श्र्","त्र","त्र्","ग्र्","व्र्","ज्र्","ह्न","प्र्","ह्र","झ्र्","प्र्","द्र",                    	    //13
"रु","रू","रू",

"क्ष","क्ष्","ज्ञ","ज्ञ्","न्न्","ष्ठ","ष्ठ","ङ्घ","ङ्ख","ङ्ग","ह्य्","ह्व","ह्ल","श्च्","द्म्","ट्ठ",      //17
"ड्ढ","ङ्क","ञ्ज्","ङ्ग","दृ","ञ्च्","व्न्","द्य्","द्भ","ङ्ख","द्व","ढ्ढ","श्व्",              //15 "ष्ट्र","ष्ट",
"द्ध","ड्ड","त्त्","ट्ट","द्ब","द्द","हृ","ठ्ठ","द्ग","ह्म्",                                //10

"ड़","ढ़",                                                           //02

"ट्र","ठ्र","ड्र","ढ्र","्रू","्रु","्र",                                         //07
"्न","्य्","्ल",                                                    //03

"क्","क","ख्","ख","ग्","ग","घ्","घ","ङ",                                    //09 
"च्","च","छ","ज़्","ज़","ज्","ज","झ्","झ","ञ्","ञ",                             //11
"ट","ठ","ड","ढ","ण्","ण",                                              //06
"त्","त","थ्","थ","द","ध्","ध","न्","न",                                    //09
"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",                                //10

"शृ","य्","य","र","ल्","ल","ळ्","ळ","व्","व","श्","श","ष्","ष","स्","स","ह्","ह",        //18 // "श्","श्",

"औ","ओ","ऑ","आ","अ","ई","इ","उ","ऊ","ऋ","ऌ","ऐ","ए",                     //13

"ौ","ो","ॉ","ा","ी","ु","ू","ृ","ॢ","े","ै","ँ","ं","ः","्","ॅ","ऽ","़",       //18

"०","१","२","३","४","५","६","७","८","९")                                  //10

var array_two = new Array("‘","’","'","d ",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  //one-byte varnas
"Dee@","òeâ","›eâ","kesâ","ke=â","kegâ","Ìkeâ","ÌHeâ","Ìpe","ÌKe","ÌÙe","Ìie","Heâ","heâ","Heä","heä",
"Ìkeä","ÌK",
"Ô","~","$e+",
"Œe","Œ","œe","œ",

"ef#e","ef$e","ef%e","efße",
"ße","ß","$e","$","«","›","¿","Ö","Ø","Ü","ã","ø","õ",
"®","™","¤", 

"#e","#","%e","%","V","…","‰","‹","“","”","¢","£","¥","§","©","ª",
"º","»","À","Á","Â","Ã","Ä","Å","Æ","È","É","Ñ","Õ",  //"°^","°",
"æ","ñ","ò","ó","ô","ö","ù","ú","û","ÿ",

"Ì[","Ì{",

"š^","\"^","[^","{^","Í","Î","Ç",
">","Ÿ","ê",

"keä","keâ","K","Ke","i","ie","I","Ie","*",     
"Û","Ûe","Ú","[p","[pe","p","pe","P","Pe","_","_",
"š","\"","[","{","C","Ce",
"l","le","L","Le","o","O","Oe","v","ve",
"h","he","heä","heâ","y","ye","Y","Ye","c","ce",

"ëe=","Ù","Ùe","j","u","}","à","U","k","ke","M","Me","<","<e","m","me","å","n",  // "ç","ë",

"Deew","Dees","Dee@","Dee","De","F&","F","G","T","$e+","è","Ss","S",

"ew","es","e@","e","er","g","t","=","ï","s","w","B","b","Š","d","@","Ó","Ê",

"0","1","2","3","4","5","6","7","8","9")

//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// The following two characters are to be replaced through proper checking of locations:
//******************************************************
//   ikAr and reph
//******************************************************
//   "ef","eq",
//   "ि","ि",
//
//   "&","N",
// "reph","reph (Marathi)",
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").value = processed_text  ;


//**************************************************

function Replace_Symbols( )
   {

    // if string to be converted is non-blank then no need of any processing.
    if (modified_substring != "" )  
       {

modified_substring = modified_substring.replace ( /त्र्य/g , "$य" )  ; 

// first replace the two-byte nukta_varNa with corresponding one-byte nukta varNas.

// 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 "ef"  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 + "ि" ,  "µ" + 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 + "µ", "µ" + 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.
 
//     modified_substring = modified_substring.replace ( /-/g , "¹" )  ; 
//     modified_substring = modified_substring.replace ( /श्र्/g , "E" )  ; 
       var space = " "
       var position_of_half_R = modified_substring.indexOf( "र्" ) ;

//************************************************************************************
   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
      {  
//       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
   } // 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 + "&" ) ;

//     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 ( /µ/g , "ef" ) 
     modified_substring = modified_substring.replace ( /d &/g , "d&" ) 
     modified_substring = modified_substring.replace ( /&Ùe/g , "NÙe" ) 
     modified_substring = modified_substring.replace ( /&er/g , "er&" ) 
     modified_substring = modified_substring.replace ( /n&/g , "Nn" ) 

 //    modified_substring = modified_substring.replace ( /-ao/g , "ao-" ) 
 //      modified_substring = modified_substring.replace ( /-a/g , "a-" )  
 //      modified_substring = modified_substring.replace ( /-I/g , "I-" )  
 //      modified_substring = modified_substring.replace ( /\ -/g , "\-" )
 //      modified_substring = modified_substring.replace ( /ki,/g , "ik," ) 
 //      modified_substring = modified_substring.replace ( /Ki,/g , "iÓ" ) 
 //      modified_substring = modified_substring.replace ( /gai,/g , "iga," ) 
 //      modified_substring = modified_substring.replace ( /fi,/g , "iÔ" ) 
 //      modified_substring = modified_substring.replace ( /Di,/g , "iD," ) 
 //      modified_substring = modified_substring.replace ( /Zi,/g , "iZ," ) 
 //      modified_substring = modified_substring.replace ( /jai,/g , "ija," ) 
 //      modified_substring = modified_substring.replace ( /nai,/g , "ina," ) 
 //      modified_substring = modified_substring.replace ( /ri,/g , "ir," ) 
 //      modified_substring = modified_substring.replace ( /Li,/g , "iL," ) 


    } // end of the function  Replace_Symbols( )

  } // end of convert_to_Prakash function



//+++++END OF PRAKASH_UNICODE_PRAKASH++++//
//+++++START of KRUTIDEV_UNICODE_KRUTIDEV+++//
function convert_Krutidev10_to_Unicode()
{

var array_one = new Array(//"kZsa", 
// "(",")", 
"ñ","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","?","³", 
"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 array_two = new Array(//"ksaZ",
//"¼","½", 
"॰","QZ+","sa","a","र्द्ध","Z","\"","\"","'","'",

"०","१","२","३","४","५","६","७","८","९",   

"फ़्","क़","ख़","ख़्","ग़","ज़्","ज़","ड़","ढ़","फ़","य़","ऱ","ऩ",    // one-byte nukta varNas
"त्त","त्त्","क्त","दृ","कृ","न्न","न्न्","=k","f=",

"ह्न","ह्य","हृ","ह्म","ह्र","ह्","द्द","क्ष","क्ष्","त्र","त्र्", 
"छ्य","ट्य","ठ्य","ड्य","ढ्य","द्य","ज्ञ","द्व",
"श्र","ट्र","ड्र","ढ्र","छ्र","क्र","फ्र","र्द्र","द्र","प्र","प्र","ग्र","रु","रू",

"ऑ","ओ","औ","आ","अ","ईं","ई","ई","इ","उ","ऊ","ऐ","ए","ऋ",

"क्क","क","क","क्","ख","ख","ख्","ग","ग","ग्","घ","घ","घ्","ङ",
"च","च","च्","छ","ज","ज","ज्","झ","झ्","ञ",

"ट्ट","ट्ठ","ट","ठ","ड्ड","ड्ढ","ड़","ढ़","ड","ढ","ण","ण्",   
"त","त","त्","थ","थ्","द्ध","द","ध","ध","ध्","ध्","ध्","न","न","न्",    

"प","प","प्","फ","फ्","ब","ब","ब्","भ","भ्","म","म","म्",  
"य","य्","र","ल","ल","ल्","ळ","व","व","व्",   
"श","श्","ष","ष्","स","स","स्","ह", 

"ीं","्र",    
"द्द","ट्ट","ट्ठ","ड्ड","कृ","भ","्य","ड्ढ","झ्","क्र","त्त्","श","श्",

"ॉ","ो","ो","ौ","ौ","ा","ी","ु","ू","ृ","े","े","ै",
"ं","ँ","ः","ॅ","ऽ","ऽ","ऽ","ऽ","्र","्","?","़",":",
"‘","’","“","”",";","(",")","{","}","=","।",".","-","µ","॰",",","् ","/",
"ो","ॉ","ैं","्रे","औ","ओ","ऑ")



var array_one_length = array_one.length ;

var modified_substring = document.getElementById("unitext").value  ;

//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = document.getElementById("unitext").value.length ;

    var processed_Unitext = '' ;  //blank
   
     var sthiti1 = 0 ;  var sthiti2 = 0 ;  var chale_chalo = 1 ;
 
    var max_text_size = 6000;

    while ( chale_chalo == 1 ) 
    {
     sthiti1 = sthiti2 ;

     if ( sthiti2 < ( text_size - max_text_size ) )  
     { 
      sthiti2 +=  max_text_size ;
      while (document.getElementById("unitext").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }

     var modified_substring = document.getElementById("unitext").value.substring ( sthiti1, sthiti2 )  ;

     Replace_Symbols1( ) ;

     processed_Unitext += modified_substring ;

     document.getElementById("Unitext").value = processed_Unitext  ;
    }


// --------------------------------------------------

function Replace_Symbols1( )
{

//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 ) //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

//**********************************************************************************
// Code for Replacing five Special glyphs
//**********************************************************************************

//**********************************************************************************
// Code for Glyph1 : ± (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /±/g , "Zं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".
//
//**********************************************************************************
// Glyp2: Æ
// code for replacing "f" with "ि" and correcting its position too. (moving it one position forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Æ/g , "र्f" ) ;  // at some places  Æ  is  used eg  in "धार्मिक".

var position_of_i = modified_substring.indexOf( "f" )

while ( position_of_i != -1 )  //while-02
{
var character_next_to_i = modified_substring.charAt( position_of_i + 1 )
var character_to_be_replaced = "f" + character_next_to_i
modified_substring = modified_substring.replace( character_to_be_replaced , character_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /f/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Glyph3 & Glyph4: Ç  É
// code for replacing "fa" with "िं"  and correcting its position too.(moving it two positions forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Ç/g , "fa" ) ; // at some places  Ç  is  used eg  in "किंकर".
modified_substring = modified_substring.replace( /É/g , "र्fa" ) ; // at some places  É  is  used eg  in "शर्मिंदा"

var position_of_i = modified_substring.indexOf( "fa" )

while ( position_of_i != -1 )  //while-02
{
var character_next_to_ip2 = modified_substring.charAt( position_of_i + 2 )
var character_to_be_replaced = "fa" + character_next_to_ip2
modified_substring = modified_substring.replace( character_to_be_replaced , character_next_to_ip2 + "िं" ) 
position_of_i = modified_substring.search( /fa/ , position_of_i + 2 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Glyph5: Ê
// code for replacing "h" with "ी"  and correcting its position too.(moving it one positions forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Ê/g , "ीZ" ) ; // at some places  Ê  is  used eg  in "किंकर".


/*
var position_of_i = modified_substring.indexOf( "h" )

while ( position_of_i != -1 )  //while-02
{
var character_next_to_i = modified_substring.charAt( position_of_i + 1 )
var character_to_be_replaced = "h" + character_next_to_i
modified_substring = modified_substring.replace( character_to_be_replaced , character_next_to_i + "ी" ) 
position_of_i = modified_substring.search( /h/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop
*/


//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var character_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( character_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

//**************************************
// 
//**************************************
//   alert(modified_substring);
//**************************************


// Eliminating reph "Z" and putting 'half - r' at proper position for this.
set_of_matras = "अ आ इ ई उ ऊ ए ऐ ओ औ ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 

var position_of_R = modified_substring.indexOf( "Z" )

// alert(" 1. modified_substring = "+modified_substring );
// alert(" 2. position_of_R = "+position_of_R )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;

 //alert(" 3. probable_position_of_half_r = "+probable_position_of_half_r );

var character_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )

 //alert(" 4. character_at_probable_position_of_half_r = "+character_at_probable_position_of_half_r );

//************************************************************
// trying to find non-maatra position left to current O (ie, half -r).
//************************************************************

while ( set_of_matras.match( character_at_probable_position_of_half_r ) != null )  // while-05
// some vowel maatraa or anusvaar found, move to previous character
   {   probable_position_of_half_r = probable_position_of_half_r - 1 ;
       character_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;
   
     //alert(" 5. probable_position_of_half_r = "+probable_position_of_half_r );
     //alert(" 6. character_at_probable_position_of_half_r = "+character_at_probable_position_of_half_r );
   } // end of while-05

//************************************************************
// check if the previous character to the present character is a halant
//************************************************************
   var previous_to_position_of_half_r = probable_position_of_half_r - 1 ;
 //alert(" 7. previous_to_position_of_half_r = "+previous_to_position_of_half_r );

   if (previous_to_position_of_half_r > 0)  // if-03
   {  var character_previous_to_position_of_half_r = modified_substring.charAt( previous_to_position_of_half_r )
    //alert(" 8. character_previous_to_position_of_half_r = "+character_previous_to_position_of_half_r );

      while ("्".match( character_previous_to_position_of_half_r ) != null ) // while-06
//    halant found, move to previous character
      {  probable_position_of_half_r = previous_to_position_of_half_r - 1 ;
         character_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

       //alert(" 9. probable_position_of_half_r = "+probable_position_of_half_r );
       //alert("10. character_at_probable_position_of_half_r = "+character_at_probable_position_of_half_r );
       
         previous_to_position_of_half_r = probable_position_of_half_r - 1 ;
         character_previous_to_position_of_half_r = modified_substring.charAt( previous_to_position_of_half_r )

       //alert("11. previous_to_position_of_half_r = "+previous_to_position_of_half_r );
       //alert("12. character_previous_to_position_of_half_r = "+character_previous_to_position_of_half_r );
      } // end of while-06
   } // end of if-03

//************************************************************

character_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + character_to_be_replaced ; 
character_to_be_replaced = character_to_be_replaced + "Z" ;
modified_substring = modified_substring.replace( character_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "Z" ) ;

 //alert("13. character_to_be_replaced = "+character_to_be_replaced );
 //alert("14. modified_substring = "+modified_substring );

} // end of while-04

} // end of IF  statement  meant to  supress processing of  blank  string.

//**************************************
//   alert(modified_substring);
//**************************************


} // end of the function  Replace_Symbols1

 
} // end of convert_Kritidev10_to_Unicode()

function ConvertUnicode_to_Krutidev_010()
{
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+","<+","Q",";","j","u",
"¶+","d+","[k+","x+","T+","t+","M+","<+","Q+",";+","j+","u+",
"Ù","Ùk","ä","–","—",       

"Üo","à","á","â","ã","ºz","º","í","{","{k","«","=","K", 
"Nî","Vî","Bî","Mî","<î","|","}",
"J","Vª","Mª","<ªª","Nª","Ø","Ý","æ","ç","xz","#",":",
"z",

"vks","vkS","vk","v","bZ","b","m","Å",",s",",","_",

"D","d","ô","[","[k","X","x","?","?k","³", 
"pkS","P","p","N","T","t","÷",">","¥",

"ê","ë","V","B","ì","ï","M","<",".",".k",   
"R","r","F","Fk",")","n","è","èk","U","u",   

"I","i","¶","Q","C","c","H","Hk","E","e",
"¸",";","j","Y","y","G","O","o",
"'","'k","\"","\"k","L","l","g",      

"v‚","‚","ks","kS","k","h","q","w","`","s","S",
"a","¡","%","W","•","~ ","~","+","@")   // "~j"
  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// 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("unitext").value  ;

//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = document.getElementById("unitext").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("unitext").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }

     var modified_substring = document.getElementById("unitext").value.substring ( sthiti1, sthiti2 )  ;

    Replace_Symbols( ) ;

    processed_text += modified_substring ;

//****************************************************************************************
//  Breaking part code over
//****************************************************************************************
//  processed_text = processed_text.replace( /mangal/g , "Krutidev010" ) ;   

    document.getElementById("output").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 , "ksZa" ) ; 
modified_substring = modified_substring.replace( /~ Z/g , "Z~" ) ; 
modified_substring = modified_substring.replace( /Zk/g , "kZ" ) ; 
modified_substring = modified_substring.replace( /Zh/g , "Ê" ) ; 

    } // end of the function  Replace_Symbols( )


  } // end of Convert_Unicode_to_Krutidev010 function

//+++++END OF KRUTIDEV_UNICODE_KRUTIDEV++++/
//++++Start of Preeti_Unicode_Preeti++++//
function convertPreeti_to_unicode()
{

var array_one = new Array( 

"ç","˜",".","'m","]m","Fmf","Fm",

")","!","@","#","$","%","^","&","*","(",

"k|m","em","km","Qm","qm","N˜",
"¡","¢","1","2","4",">","?","B","I","Q","ß",
"q","„","‹","•","›","§","°","¶","¿","Å",   
"Ë","Ì","Í","Î","Ý","å",
"6«","7«","8«","9«",

"Ø","|",

"8Þ","9Þ",

"S","s","V","v","U","u","£","3","ª",
"R","r","5","H","h","‰","´","~", "`",

"6","7","8","9","0",
"T","t","Y","y","b","W","w","G","g",  

"K","k","ˆ","A","a","E", "e","D","d",
"o","/","N","n","J", "j", "Z","z","i",":",";","X","x", 

"cf‘","c‘f","cf}","cf]","cf","c","O{","O","pm","p","C","P]","P",

"f‘","\"","'","+","f","[","\\","]","}","F", "L","M",

"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ाे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे")     // Remove typing mistakes in the original file

//"_","Ö","Ù","Ú","Û","Ü","Þ","Æ","±","-","<","=")    // Punctuation marks

var array_two = new Array(

"ॐ","ऽ","।","m'","m]","mfF","mF",

"०","१","२","३","४","५","६","७","८","९",

"फ्र","झ","फ","क्त","क्र","ल",
"ज्ञ्","द्घ","ज्ञ","द्द","द्ध","श्र","रु","द्य","क्ष्","त्त","द्म", 
"त्र","ध्र","ङ्घ","ड्ड","द्र","ट्ट","ड्ढ","ठ्ठ","रू","हृ",   
"ङ्ग","त्र","ङ्क","ङ्ख","ट्ठ","द्व",
"ट्र","ठ्र","ड्र","ढ्र",

"्य","्र",

"ड़","ढ़",

"क्","क","ख्","ख","ग्","ग","घ्","घ", "ङ",
"च्","च","छ","ज्","ज","झ्","झ","ञ्", "ञ",

"ट","ठ","ड","ढ","ण्",
"त्","त","थ्","थ","द","ध्","ध","न्","न",  

"प्","प","फ्","ब्","ब","भ्","भ","म्","म",
"य","र","ल्","ल","व्","व","श्","श","ष्","स्","स","ह्","ह",

"ऑ","ऑ","औ","ओ","आ","अ","ई","इ","ऊ","उ","ऋ","ऐ","ए",

"ॉ","ू","ु","ं","ा","ृ","्","े","ै","ँ","ी","ः",

"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ो",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें")     // Remove typing mistakes in the original file 

//  ")","=", ";", "’","!","%",".","”","+","(","?",".")       // Punctuation marks

//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
//  "l", 
//  "ि",
//
// "{"
// "र्" (reph) 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************
var position_of_i = modified_substring.indexOf( "l" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "l" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /l/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ô" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "{" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "{" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "{" ) ;

} // end of while-04

// global conversion of punctuation marks
//    "=","_","Ö","Ù","‘","Ú","Û","Ü","æ","Æ","±","-","<",  
//    ".",")","=", ";","…", "’","!","%","“","”","+","(","?",

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 , "“" )   ;  
modified_substring = modified_substring.replace( /Æ/g , "”" )   ;  
modified_substring = modified_substring.replace( /±/g , "+" )   ;  
modified_substring = modified_substring.replace( /-/g , "(" )   ;  
modified_substring = modified_substring.replace( /</g , "?" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function

//*******************************************************************************
function convertUnicode_to_Preeti()
{
var array_one = new Array(
"‘","?",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  // two-byte varnas            // 7

"ॐ","ऽ","।","m'","m]","mfF","mF",

"०","१","२","३","४","५","६","७","८","९",

"फ्र","झ","फ","क्त","क्र","ल",
"ज्ञ्","द्घ","ज्ञ","द्द","द्ध","श्र","रु","द्य","क्ष्","क्ष","त्त","द्म", 
"त्र","ध्र","ङ्घ","ड्ड","द्र","ट्ट","ड्ढ","ठ्ठ","रू","हृ",   
"ङ्ग","त्र","ङ्क","ङ्ख","ट्ठ","द्व",
"ट्र","ठ्र","ड्र","ढ्र",

"्र",

"ड़","ढ़",

"क्","क","ख्","ख","ग्","ग","घ्","घ", "ङ",
"च्","च","छ","ज्","ज","झ्","झ","ञ्", "ञ",

"ट","ठ","ड","ढ","ण्","ण",
"त्","त","थ्","थ","द","ध्","ध","न्","न",  

"प्","प","फ्","ब्","ब","भ्","भ","म्","म",
"य","र","ल्","ल","व्","व","श्","श","ष्","ष","स्","स","ह्","ह",

"्य",

"ऑ","ऑ","औ","ओ","आ","अ","ई","इ","ऊ","उ","ऋ","ऐ","ए",

"ॉ","ू","ु","ं","ा","ृ","्","े","ै","ँ","ी","ः","ो","ौ")

var array_two = new Array( 
"…","<",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  //one-byte varnas                  // 7

"ç","˜",".","'m","]m","Fmf","Fm",

")","!","@","#","$","%","^","&","*","(",

"k|m","em","km","Qm","qm","N˜",
"¡","¢","1","2","4",">","?","B","I","If","Q","ß",
"q","„","‹","•","›","§","°","¶","¿","Å",   
"Ë","Ì","Í","Î","Ý","å",
"6«","7«","8«","9«",

"|",

"8Þ","9Þ",

"S","s","V","v","U","u","£","3","ª",
"R","r","5","H","h","‰","´","~", "`",

"6","7","8","9","0","0f",
"T","t","Y","y","b","W","w","G","g",  

"K","k","ˆ","A","a","E", "e","D","d",
"o","/","N","n","J", "j", "Z","z","i","if",":",";","X","x", 

"Ø",

"cf‘","c‘f","cf}","cf]","cf","c","O{","O","pm","p","C","P]","P",

"f‘","\"","'","+","f","[","\\","]","}","F", "L","M","f]","f}")

  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// The following two characters are to be replaced through proper checking of locations:

// "र्" (reph) 
// "R" )

// "ि"  
// "i" )


    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").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 ( /क़/ , "क़" )  ; 
// 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 "i"  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 + "ि" ,  "l" + 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 + "l", "l" + 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 space = " "
       var position_of_half_R = modified_substring.indexOf( "र्" ) ;

//************************************************************************************
   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
      {  
//       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
   } // 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 + "{" ) ;

//     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 ( /-ao/g , "ao-" ) 


    } // end of the function  Replace_Symbols( )

  } // end of convert_to_Preeti function


//+++++End of Preeti_unicode_Preeti++++//
//++++Start of Shusha_Unicode_Shusha+++//
function convertShusha_to_unicode()
{

var array_one = new Array( 
"D,","Z,","¹","Ñ","º",".","Â","³","´","¡","£","¤","¥","À",
"!","?’","?”","? ",",D",
"$","&","(",")","+","<",">","E","V","W","_","w","x","{","~","œ","Ÿ",
"É","Ë","Ì","Í","Î", // "Ø",
"`","/",

"@","k,","k","#","K,","K","Ó","ga,","g","G", "=",  
"c","C","j,","ja,","j","J","H",
"T","z","D","Z","N",
"%","t","q","d","Q","n",
"P","p","F,","f,","F","f","Ô","b","B","m",

"y","r","l","L","v","S","X","Ï","Y","s","*","h",

"AaO","Aao","Aa^","Aa","A","š","[-","[","]","}","?",";","eo", "e",     

"aO","ao","a","I","u","U","R","o","O","Ð","M",":","\\","^","|","º","¹","Ñ",",","¸", // ",",

"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ॅा","ाे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे","ाें","ॅं","ंॅ"," ः","ंू")     // Remove typing mistakes in the original file

var array_two = new Array(
"ड़","ढ़","–","!",".","।",";","(",")","{","}","[","]","/",
"ॐ","Æ’","Æ”","Æ ","ड़",
"रू","ज्ञ","ह्य","हृ","ट्ट","त्त्","क्त","श्र्","द्य","द्व","द्द","द्ध","क्ष्","ठ्ठ","त्र","ह्र","जि",
"रु","क्र","कृ","फ्र","फृ", // "न्न",
"्र","्र",

"क्","क़","क","ख्","ख़","ख","ख़","ग़","ग्", "घ्", "ङ",  
"च्","छ","ज़्","ज़","ज्","झ्","ञ्",
"ट","ठ","ड","ढ","ण्",
"त्","त","थ्","द","ध्","न्",
"प्","प","फ़्","फ़","फ्","फ","फ़","ब्","भ्","म्",

"य्","र","ल्","ळ","व्","श्","श्","श्","ष्","स्","ह्","ह",

"औ","ओ","ऑ","आ","अ","ई","ई","इ","उ","ऊ","ऋ","ऌ","ऐ","ए",   

"ौ","ो","ा","ी","ु","ू","ृ","े","ै","ँ","ं","ः","्","ॅ","ऽ","़","–","!",".",",", // "़",

"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ॉ","ो",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें","ों","ँ","ँ"," :","ूं")     // Remove typing mistakes in the original file 

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
//   "i",
//   "ि",
//
//   "-",
// "र्" (reph) 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************
var position_of_i = modified_substring.indexOf( "i" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "i" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /i/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Ô" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "-" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "-" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "-" ) ;

} // end of while-04

//**********punctuation marks ****************
//    "¡","£","¤","¥","²","³","´","µ","¹","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","Ê","Ñ","Ò","Õ",
// "{","}","[","]","!","(",")","*","-","/",":",";","<","=",">","?","@","|",",","!","\\","√","-",

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 , "?" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function


//*******************************************************************************
function convertUnicode_to_Shusha()
{
var array_one = new Array(
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  // two-byte varnas
"!",".","।",";","(",")","{","}","[","]","/","<","=",">",",","+","*","%",
"ख़्","ख़","फ़्","फ़",
//"क़ि","ख़ि","ग़ि","ज़ि","ड़ि","ढ़ि","फ़ि", 
"ॐ", "?", // "Æ’","Æ”","Æ ",
"ज्ञ","ह्य","हृ","ट्ट","त्त्","क्त","श्र","द्य","द्व","द्द","द्ध","क्ष्","क्ष","ठ्ठ","त्र","ह्र","जि",
"क्रु","क्रू","्रु","्रू","रू","रु",
"क्र","कृ","फ्र","फृ", //"न्न",
"ड़","ढ़",
"ट्र","ड्र","ढ्र","्र",

"क़","ग़","ज़्",
"क्","क","ख्","ख","ग्","ग","घ्","घ","ङ",  
"च्","च","छ","ज़","ज्","ज","झ्","झ","ञ्","ञ",
"ट","ठ","ड","ढ","ण्","ण",
"त्","त","थ्","थ","द","ध्","ध","न्","न",
"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",

"य्","य","र","ल्","ल","ळ","व्","व","श्","श","ष्","ष","स्","स","ह्","ह", // "श्","श्",

"औ","ओ","ऑ","आ","अ","ई","ई","इ","उ","ऊ","ऋ","ऌ","ऐ","ए",   

"ौ","ो","ॉ","ा","ी","ु","ू","ृ","े","ै","ँ","ं",":","ः","्","ॅ","ऽ","़")

var array_two = new Array( 
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  //one-byte varnas
"Ñ","º",".","Â","³","´","¡","£","¤","¥","À","Ã","Ä","Å","¸","†","µ","‰",
"K,","Ó","F,","Ô",
//"ik¸","iK¸","iga¸","ija¸","iD¸","iZ¸","iPa¸", 
"!","Æ", // "?’","?”","? ",
"&","(",")","+","<",">","Ea","V","W","_","w","x","xa","{","~","œ","Ÿ",
"Ëu","Ëu","`u","`U","$","É",
"Ë","Ì","Í","Î", // "Ø",
"D,","Z,",
"T/","D/","Z/","`",

"k,","ga,","j,",
"@","k","#","K","g","ga","G","Ga","=",  
"c","ca","C","ja,","j","ja","J","Ja","H","Ha",
"T","z","D","Z","N","Na",
"%","t","q","qa","d","Q","Qa","n","na",
"P","p","F","f","b","ba","B","Ba","m","ma",

"y","ya","r","l","la","L","v","va","S","Sa","Y","Ya","s","sa","*","h", // "X","Ï",

"AaO","Aao","Aa^","Aa","A","š","[-","[","]","}","?",";","eo", "e",     

"aO","ao","a^","a","I","u","U","R","o","O","Ð","M","Á",":","\\","^","|",",")
  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// 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("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").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 ( /क़/ , "क़" )  ; 
// 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 "i"  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 + "ि" ,  "i" + 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 + "i", "i" + 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.
  
      modified_substring = modified_substring.replace ( /-/g , "¹" )  ; 
      modified_substring = modified_substring.replace ( /श्र्/g , "E" )  ; 
      modified_substring = modified_substring.replace ( /त्र्य/g , "~\\ya" )  ; 

       var space = " "
       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 + "-" ) ;

//     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 ( /-ao/g , "ao-" ) 
       modified_substring = modified_substring.replace ( /-a/g , "a-" )  
       modified_substring = modified_substring.replace ( /-I/g , "I-" )  
       modified_substring = modified_substring.replace ( /\ -/g , "\-" )
       modified_substring = modified_substring.replace ( /ki,/g , "ik," ) 
       modified_substring = modified_substring.replace ( /Ki,/g , "iÓ" ) 
       modified_substring = modified_substring.replace ( /gai,/g , "iga," ) 
       modified_substring = modified_substring.replace ( /fi,/g , "iÔ" ) 
       modified_substring = modified_substring.replace ( /Di,/g , "iD," ) 
       modified_substring = modified_substring.replace ( /Zi,/g , "iZ," ) 
       modified_substring = modified_substring.replace ( /jai,/g , "ija," ) 
       modified_substring = modified_substring.replace ( /nai,/g , "ina," ) 
       modified_substring = modified_substring.replace ( /ri,/g , "ir," ) 
       modified_substring = modified_substring.replace ( /Li,/g , "iL," ) 


    } // end of the function  Replace_Symbols( )

  } // end of convert_to_Shusha function

//+++++End of Shush_Unicode_Shusha+++//
//++++start of Chandni_Unicode_Chandni+++//
function convertChandni_to_unicode()
{

var array_one = new Array( "ñ",

"å",  "ƒ",  "„",   "…",   "†",   "‡",   "ˆ",   "‰",   "Š",   "‹", "~ ",

"¶+",   "d+",    "[k+",  "x+",  "T+",  "t+",   "M+", "<+", "Q+",  ";+",    "j+",   "u+",
"Ùk", "Ù", "ä", "–", "—",       

"à",   "á",    "â",   "ã",   "ºz",  "º",   "í", "{k", "{", "=",  "«",   
"Nî",   "Vî",    "Bî",   "Mî",   "<î", "|", "K", "}",
"J",   "Vª",   "Mª",  "<ªª",  "Nª",   "Ø",  "Ý",   "æ", "ç", "Á", "xz", "#", ":",

"vks",  "vkS",  "vk",    "v",  "b±", "Ã",  "bZ",  "b",  "m",  "Å",  ",s",  ",",   "_",

"ô",  "d", "Dk", "D", "[k", "[", "x","Xk", "X", "Ä", "?k", "?",   "³", 
"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®", 
"Ì", "Í", "Î",  "Ï",  "Ñ",  "Ò",  "Ó",  "Ô",   "Ö",  "Ø",  "Ù", "Ü","ò",

"v‚",    "‚",    "ks",   "kS",   "k",  "h",    "q",   "w",   "`",    "s",    "S",
"a",    "¡",    "%",     "W",  "•", "•", "∙", "•", "~j",  "~", "\\","+",
"^", "*",  "Þ", "ß", "(", "¼", "½", "¿", "À", "¾", "A", "-", "&", "&", "Œ", "]",
"ाॅ","आॅ","ंु","ंू","ंं","ेे","ूू")

var array_two = new Array( "॰",

"०",  "१",  "२",  "३",     "४",   "५",  "६",   "७",   "८",   "९",  "् ", 

"फ़्",  "क़",  "ख़",  "ग़", "ज़्", "ज़",  "ड़",  "ढ़",   "फ़",  "य़",  "ऱ",  "ऩ",    // one-byte nukta varNas
"त्त", "त्त्", "क्त",  "दृ",  "कृ",

"ह्न",  "ह्य",  "हृ",  "ह्म",  "ह्र",  "ह्",   "द्द",  "क्ष", "क्ष्", "त्र", "त्र्", 
"छ्य",  "ट्य",  "ठ्य",  "ड्य",  "ढ्य", "द्य", "ज्ञ", "द्व",
"श्र",  "ट्र",    "ड्र",    "ढ्र",    "छ्र",   "क्र",  "फ्र",  "द्र",   "प्र", "प्र",  "ग्र", "रु",  "रू",

"ओ",  "औ",  "आ",   "अ", "ईं", "ई",  "ई",   "इ",  "उ",   "ऊ",  "ऐ",  "ए", "ऋ",

"क्क", "क", "क", "क्", "ख", "ख्", "ग", "ग", "ग्", "घ", "घ", "घ्", "ङ",
"च", "च", "च्", "छ", "ज", "ज", "ज्",  "झ",  "झ्", "ञ",

"ट्ट",   "ट्ठ",   "ट",   "ठ",   "ड्ड",   "ड्ढ",  "ड़", "ढ़", "ड",   "ढ", "ण", "ण्",   
"त", "त", "त्", "थ", "थ्",  "द्ध",  "द", "ध", "ध", "ध्", "ध्", "ध्", "न", "न", "न्",    

"प", "प", "प्",  "फ", "फ्",  "ब", "ब", "ब्",  "भ", "भ्",  "म",  "म", "म्",  
"य", "य्",  "र", "ल", "ल", "ल्",  "ळ",  "व", "व", "व्",   
"श", "श्",  "ष", "ष्", "स", "स", "स्", "ह", 

"ीं", "्र","ैं","ौं",    
"ध", "ट्ट","ट्ठ","ड्ड","कृ","भ","्य","ड्ढ","झ्","क्र","त्त्","श्","स्र",

"ऑ",   "ॉ",  "ो",   "ौ",   "ा",   "ी",   "ु",   "ू",   "ृ",   "े",   "ै",
"ं",   "ँ",   "ः",   "ॅ",  "ऽ", "ऽ", "ऽ", "ऽ", "्र",  "्", "?", "़",
"‘",   "’",   "“",   "”",  ";",  "(",    ")",   "{",    "}",   "=", "।", ".", "-",  "µ", "॰", ",",
"ॉ","ऑ","ुं","ूं","ं","े","ू")

// The following two characters are to be replaced through proper checking of locations:
// "Z" )
// "र्" (reph) 

// "f" )
// "ि"  


    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").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 ) //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

//**********************************************************************************
// Code for Replacing five Special glyphs
//**********************************************************************************

//**********************************************************************************
// Code for Glyph1 : ± (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /±/g , "Zं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".
  
//
//**********************************************************************************
// Glyp2: Æ
// code for replacing "f" with "ि" and correcting its position too. (moving it one position forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Æ/g , "र्f" ) ;  // at some places  Æ  is  used eg  in "धार्मिक".

var position_of_i = modified_substring.indexOf( "f" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "f" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /f/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Glyph3 & Glyph4: Ç  É
// code for replacing "fa" with "िं"  and correcting its position too.(moving it two positions forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Ç/g , "fa" ) ; // at some places  Ç  is  used eg  in "किंकर".
modified_substring = modified_substring.replace( /É/g , "र्fa" ) ; // at some places  É  is  used eg  in "शर्मिंदा"

var position_of_i = modified_substring.indexOf( "fa" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_ip2 = modified_substring.charAt( position_of_i + 2 )
var charecter_to_be_replaced = "fa" + charecter_next_to_ip2
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_ip2 + "िं" ) 
position_of_i = modified_substring.search( /fa/ , position_of_i + 2 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Glyph5: Ê
// code for replacing "h" with "ी"  and correcting its position too.(moving it one positions forward)
//**********************************************************************************

modified_substring = modified_substring.replace( /Ê/g , "ीZ" ) ; // at some places  Ê  is  used eg  in "किंकर".


/*
var position_of_i = modified_substring.indexOf( "h" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "h" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ी" ) 
position_of_i = modified_substring.search( /h/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop
*/


//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph "Z" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "Z" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "Z" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "Z" ) ;

} // end of while-04

} // end of IF  statement  meant to  supress processing of  blank  string.


} // end of the function  Replace_Symbols


} // end of convert_to_unicode function

//*******************************************************************************
function convertUnicode_to_Chandni()
{

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+", "<+", "Q",  ";",    "j",   "u",
"Ù",   "Ùk",   "ä",    "n`",  "Ñ",       

"Ð","à",   "á",    "â",   "ã",   "gª",  "º",   "í", "{", "{k",  "«", "=","K", //"ºz",
"Nî",   "Vî",    "Bî",   "Mî",   "<î", "|","}","ð", ")",
"J",   "Vª",   "Mª",  "<ªª",  "Nª",   "Ø",  "Ý",   "æ", "ç","Hkz", "xz", "#", ":",
"z",
"vks",  "vkS",  "vk",    "v",   "bZ",  "b",  "m",  "Å",  ",s",  ",",   "_",

"D",  "d",    "ô",     "[",     "[k",    "X",   "x",  "?",    "?k",   "³", 
"pkS",  "P",    "p",  "N",   "T",    "t",   "÷",  ">",  "×", "´",

"ê", "ë",  "V",  "B",   "ì",  "ï",     "M",  "<",  ".", "Æ",   
"R",  "r",  "F", "Fk", "n", "/",  "/k",  "U", "u",   

"I",  "i",   "¶", "Q",   "C",  "c",  "H",  "Hk", "E",   "e",
"¸",   ";",    "j",  "Y",   "y",  "G",  "O",  "o",
"'", "'k",  "\"", "\"k", "L",   "l",   "g",      

"ö","®","k®",
"vkW",    "kW",    "ks",   "kS",   "k",     "h",    "q",   "w",   "`",    "s",    "S",
"a",    "¡",    "%",     "W",   "•",  "~j",  "~","-")

//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// 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("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").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 , "ख़" )  ;
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.

    } // end of the function  Replace_Symbols( )

  } // end of Convert_to_Chandni function
//+++End of Chandni_Unicode_Chandni++++//

//+++Start Sahara_Unicode_Sahara+++//
function convertSahara_to_unicode()
{

var array_one = new Array("•",
"Q","`","ä",

"A","•","H","Y","†","‹","—","°","Î","Õ","Ú","Û","æ","ó",
"ú","ü","ÿ",
"E","G","]","‡","‰","£","¤","§","¨","®","¿","Ê","Ë","Ù",
"á","â","è","ô","õ","ù","û","Œ",

"„","s","S","î","x","È","X","Z",
"…","v","V","©","c","C","|",
"U","I","O","P","Ç","J",
"¬","f","Ò","F","r","ø","R","ï","e",
"Ø","w","Ó","W","¥","q","Á","z","ç","a",

"÷","u","j","Ï","M","ñ","m","“","‚","y","˜","«","K","›","L","µ",
"t","ë","o",
"´","Ü",">",

"[","T","$","B","N","^","<",

"ß","å","ò","k","h","Ì","b","ˆ","n","{","Ã","l","p","¸","i","}","~",":","\"","&","d","p",
"D","\\",

"Ö","¯","ì","Ä","É","–","Æ","Ÿ","‘","±",

"#","@","{","ƒ","¢","ª","¶","À","Ô",
"»","œ",
"्ा","्ो","्ौ","अो","अा","आै","आे","ाो","ाॅ","ॅा","ाे","एे",
"ंु","ेे","अै","ाे","अे","ंा","अॅ","ाै","ैा","ंृ",
"ँा","ँू","ेा","ंे","ाें","ॅं","ंॅ"," ः","ंू","््","ý",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़")  // two-byte varnas     //  Remove typing mistakes in the original file

var array_two = new Array("ý",
"ॐ","।","Rs",

"ज्ञ","क्ष्","क्ष","त्त","द्य","ष्ठ","त्त्","द्म","ह्म","द्व","श्न","द्ध","ट्ठ","द्द",
"द्भ","ज्ञ्","द्ब",
"श्र","त्र","्र", "क्र","हृ","स्र","ब्र","फ्र","रू","त्र्","ध्र","व्र","ज्र","रु",
"क्र","ख्र","ह्र","त्र","भ्र","द्र","म्र","थ्र",

"क्","क","ख","ग्","ग","घ्","घ","ङ",
"च्","च","छ","ज्","ज","झ","ञ्",
"ट","ठ","ड","ढ","ण्","ण",
"त्","त","थ्","थ","द","ध्","ध","न्","न",
"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",

"य्","य","र","ळ्","ळ","ल्","ल","ल","व्","व","श्","श्","श","ष्","ष","स्",
"स","ह्","ह",
"ड़","ढ़","्य",

"अ","इ","ई","उ","ऊ","ऋ","ए",

"ीं","ें","ैं","ा","ी","ु","ु","ू","ू","ृ","े","े","ै","ै","ं","ऽ",":","ः","ॅ","ँ","्","ै",
"्","़",

"०","१","२","३","४","५","६","७","८","९",

"’","‘","ऽ","]","[","-","-","÷","्र",
"'ं","'े",
"","े","ै","ओ","आ","औ","ओ","ो","ॉ","ॉ","ो","ऐ",
"ुं","े","अ‍ै","ो","अ‍े","ां","अ‍ॅ","ौ","ौ","ृं",
"ाँ","ूँ","ो","ें","ों","ँ","ँ"," :","ूं","्","ख्",
"क़","ख़","ग़","ज़","ड़","ढ़","फ़")  //one-byte varnas     // Remove typing mistakes in the original file 

//**************************************************************************************
//
// Punctuation marks incorporated at the end
//
//**************************************************************************************
// The following two characters are to be replaced through proper checking of locations:
//**************************************************************************************
//   "g",
//   "ि",
//
//   "'",
// "र्" (reph) 
//**************************************************************************************

    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;
   // alert(" array_one_length = "+array_one_length);
   // alert("1. modified_substring = "+modified_substring );


    Replace_Symbols( ) ;

    processed_text = modified_substring ;
     
    document.getElementById("unitext").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++ )

{ 

//  alert(" modified substring = "+modified_substring)

//***********************************************************
// if (input_symbol_idx==106) 
//  { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" input_symbol_idx = "+input_symbol_idx)
//; alert(" character =" + modified_substring.CharCodeAt(input_symbol_idx))
//     alert(" character = "+modified_string.fromCharCode(input_symbol_idx)) 
//   }
// if (input_symbol_idx == 107) 
//   { alert(" input_symbol_idx = "+input_symbol_idx);
//    alert(" character = ",+string.fromCharCode(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] )
 //  alert("16. modified_substring = "+modified_substring );

idx = modified_substring.indexOf( array_one[input_symbol_idx] )

} // end of while-00 loop
// alert(" end of while loop")
} // end of for loop
// alert(" end of for loop")

// alert(" modified substring2 = "+modified_substring)
//*******************************************************
var position_of_i = modified_substring.indexOf( "g" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "g" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /g/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "िं्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 3 )
var charecter_to_be_replaced = "िं्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "िं" ) 
position_of_wrong_ee = modified_substring.search( /िं्/ , position_of_wrong_ee + 3 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Eliminating reph (straight single quote)and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "'" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "'" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "'" ) ;

} // end of while-04

//**********punctuation marks ****************
//    "¡","£","¤","¥","²","³","´","µ","¹","À","Á","Â","Ã","Ä","Å","Æ","Ç","È","Ê","Ñ","Ò","Õ",
// "{","}","[","]","!","(",")","*","-","/",":",";","<","=",">","?","@","|",",","!","\\","√","-",

//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 , "?" )   ;  

} // end of IF  statement  meant to  supress processing of  blank  string.

} // end of the function  Replace_Symbols

} // end of convert_to_unicode function


//*******************************************************************************
function convertUnicode_to_Sahara()
{
var array_one = new Array(
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  // two-byte varnas
"ॐ","।","Rs",

"ज्ञ","क्ष्","क्ष","त्त","द्य","ष्ठ","त्त्","द्म","ह्म","द्व","श्न","द्ध","ट्ठ","द्द",
"द्भ","ज्ञ्","द्ब",
"श्र","त्र","क्र","हृ","स्र","ब्र","फ्र","रू","त्र्","ध्र","व्र","ज्र","रु",
"क्र","ख्र","ह्र","त्र","भ्र","द्र","म्र","थ्र",
"छ्र","ट्र","ठ्र","ड्र","ढ्र","्र",

"क्","क","ख","ग्","ग","घ्","घ","ङ",
"च्","च","छ","ज्","ज","झ","ञ्",
"ट","ठ","ड","ढ","ण्","ण",
"त्","त","थ्","थ","द","ध्","ध","न्","न",
"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",

"य्","य","र","ळ्","ळ","ल्","ल","ल","व्","व","श्","श्","श","ष्","ष","स्",
"स","ह्","ह",
"ड़","ढ़","्य",

"औ","ओ","ऑ","आ","अ","इ","ई","उ","ऊ","ऋ","ऐ","ए",

"ॉ","ीं","ें","ैं","ौ","ो","ा","ी","ु","ु","ू","ू","ृ","े","े","ै","ै","ं","ऽ","ः","ॅ","ँ","्","ै",
"्","़",

"०","१","२","३","४","५","६","७","८","९")


//"ौ","ो","ॉ","ा","ी","ु","ू","ृ","े","ै","ँ","ं",":","ः","्","ॅ","ऽ","़")

var array_two = new Array( 
"क़","ख़","ग़","ज़","ड़","ढ़","फ़",  //one-byte varnas
"Q","`","ä",

"A","•","H","Y","†","‹","—","°","Î","Õ","Ú","Û","æ","ó",
"ú","ü","ÿ",
"E","G","‡","‰","£","¤","§","¨","®","¿","Ê","Ë","Ù", 
"á","â","è","ô","õ","ù","û","Œ",
"V]","U]","I]","O]","P]","्Ô",

"„","s","S","î","x","È","X","Z",
"…","v","V","©","c","C","|",
"U","I","O","P","Ç","J",
"¬","f","Ò","F","r","ø","R","ï","e",
"Ø","w","Ó","W","¥","q","Á","z","ç","a",

"÷","u","j","Ï","M","ñ","m","“","‚","y","˜","«","K","›","L","µ",  //"]","Ô",
"t","ë","o",
"´","Ü",">",

"[kp","[kl","[k\"","[k","[","T","$","B","N","^","<l","<",

"k\"","ß","å","ò","kp","kl","k","h","b","Ì","n","ˆ","{","l","Ã","p","¸","i","}",":","\"","&","d","p",
"D","\\",

"Ö","¯","ì","Ä","É","–","Æ","Ÿ","‘","±")

//"AaO","Aao","Aa^","Aa","A","š","[-","[","]","}","?",";","eo", "e",     

//"aO","ao","a^","a","I","u","U","R","o","O","Ð","M","Á",":","\\","^","|",",")
  
//************************************************************
//Put "Enter chunk size:" line before "<textarea name= ..." if required to be used.    
//************************************************************
//Enter chunk size: <input type="text" name="chunksize" value="6000" size="7" maxsize="7" style="text-align:right"><br/><br/>
//************************************************************
// The following two characters are to be replaced through proper checking of locations:

//   "g",
//   "ि",
//
//   "'",
// "र्" (reph) 


    var array_one_length = array_one.length ;

    var modified_substring = document.getElementById("unitext").value  ;

    Replace_Symbols( ) ;

    processed_text = modified_substring ;

    document.getElementById("output").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 ( /क़/ , "क़" )  ; 
// 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 "g"  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 + "ि" ,  "g" + 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 + "g", "g" + 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  '  at proper position for this.

       set_of_matras = "ािीुूृेैोौं:ँॅ" 

modified_substring += '  '    ;  // add two spaces after the string to avoid UNDEFINED char in the following code.
//       modified_substring = modified_substring.replace ( /-/g , "¹" )  ; 
//       modified_substring = modified_substring.replace ( /श्र्/g , "E" )  ; 
       var space = " "
       var position_of_half_R = modified_substring.indexOf( "र्" ) ;

//************************************************************************************
   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
      {  
//       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
   } // 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 + "'" ) ;

//     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 ( /'h/g , "h'" ) 
//       modified_substring = modified_substring.replace ( /-a/g , "a-" )  
//       modified_substring = modified_substring.replace ( /-I/g , "I-" )  
//       modified_substring = modified_substring.replace ( /\ -/g , "\-" )
//       modified_substring = modified_substring.replace ( /ki,/g , "ik," ) 
//       modified_substring = modified_substring.replace ( /Ki,/g , "iÓ" ) 
//       modified_substring = modified_substring.replace ( /gai,/g , "iga," ) 
//       modified_substring = modified_substring.replace ( /fi,/g , "iÔ" ) 
//       modified_substring = modified_substring.replace ( /Di,/g , "iD," ) 
//       modified_substring = modified_substring.replace ( /Zi,/g , "iZ," ) 
//       modified_substring = modified_substring.replace ( /jai,/g , "ija," ) 
//       modified_substring = modified_substring.replace ( /nai,/g , "ina," ) 
//       modified_substring = modified_substring.replace ( /ri,/g , "ir," ) 
//       modified_substring = modified_substring.replace ( /Li,/g , "iL," ) 


    } // end of the function  Replace_Symbols( )

  } // end of convert_to_Sahara function

//+++End of Sahara_Unicode_Sahara+++//
//++++Start of DV_TTSurekhEN_Unicode++//
function convertDV_TTSurekhEN_to_unicode()
{

var array_one = new Array( "$","&","*","£Ã",  // "%",

"+Éä","+Éè","+É","+",   '<È',   "<Ç","<",">","=","@","A",  "Bå",   "Bä", "‹ä", "B", "‹", "आå", "आé",   

"C","D","E","F","G","H","I","J","K","L","M","N","O",
"P","Q","R","S","T","U","V","W","X","Y","Z","[","\\","]","^","_",

"`","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o",
"p","q","r","s","t","u","v","w","x","y","z","{","|","}","~",

"¡","¢","£","¤","¥","¦","§","¨","©","ª","«","®","¯",  "¬",     
"°","±","²","³","´","µ","¶", "•", '•', "¸","¹","º","»",  

"À", "Á", "¾", "¿", "¼", "½",
"Â", "Ã", "Ä", "Æ", "Å",

"ä","è","Éä","Éè","É","Ò","Ö","×","Ù","Ú","Ý","Þ","ß","्ा",
"å","é","ì",

"ð","ñ","ò","ó","ô","õ","ö","÷","ø","ù","ú","û","ü","ý","þ",
"ाे","ाै","आॅ","ाॅ" ,  "\'", 'रू '   )


var array_two = new Array( "ॐ","ः","।","फ़्र",  // "ऽ",

"ओ","औ","आ","अ",   "ईं",   "ई","इ","ऊ","उ","ऋ","ॠ",  'ऐं',  "ऐ", "ऐ", "ए", "ए", "ओं", "औं",

"क्","क़्","क","क़","क्र","क्त","क्ष्","ख्","ख़्","ख्र्","ग्","ग़्","ग्र्",
"घ्","घ्र्","ङ","च्","च्र्","छ","ज्","ज़्","ज्र्","ज्ञ्","झ्","झ्र्","ञ्","ट","ट्ट","ट्ठ",

"ठ","ठ्ठ","ड","ड़","ड्ड","ड्ढ","ढ","ढ़","ण्","त्","त्र्","त्त्","थ्","थ्र्","द","दृ",
"द्र","द्द" ,"द्ध","द्म","द्य","द्व","ध्","ध्र्","न्","न्र्","न्न्","प्","प्र्","फ्","फ़्",

"फ","फ़","फ्र","ब्","ब्र्","भ्","भ्र्","म्","म्र्","य्","य्र्","र","रु",   "्य",     
"रू","ल्","ळ्","ळ","व्","व्र्","श्", "श्व्", 'श्व्', "श्र्","ष्","स्","स्र्",

"ह्म", "ह्य", "हृ", "ह्र", "ह्", "ह",
"्", "़", "ँ", "ं", "्र",

"े","ै","ो","ौ","ा","ी","ु","ु","ु","ू","ू","ृ","ॄ","",
"ें","ैं","ॅ",

"","","","","","","","","","","","","","","",
"ो","ौ","ऑ","ॉ" ,  '\"', ' डिग्री ' )

//***********************************************************
// The following two characters are to be replaced through proper checking of locations:
//*********************************************************
// "Ç" 
// "र्" (reph) 
//
// "Ê"  or "Î"
// "ि"  
//************************************************************

var array_one_length = array_one.length ;


    var modified_substring = document.getElementById("unitext").value  ;

//************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//************************************************************
    var text_size = document.getElementById("unitext").value.length ;

    var processed_text = '' ;  //blank

//**********************************************
//    alert("text size = "+text_size);
//**********************************************

    var sthiti1 = 0 ;  var sthiti2 = 0 ;  var chale_chalo = 1 ;
 
    var max_text_size = 6000;

    while ( chale_chalo == 1 ) 
    {
     sthiti1 = sthiti2 ; 

     if ( sthiti2 < ( text_size - max_text_size ) )  
     { 
      sthiti2 +=  max_text_size ;
      while (document.getElementById("unitext").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }
      
//     alert(" sthiti 1 = "+sthiti1); alert(" sthit 2 = "+sthiti2) 

     var modified_substring = document.getElementById("unitext").value.substring ( sthiti1, sthiti2 )  ;

    Replace_Symbols( )  ;

    processed_text += modified_substring ;

    document.getElementById("unitext").value = processed_text  ;

   }  // chalechalo while loop  ends



//---------- End of the code for maintaining small braketed content intact-------------
//************************************************************


// --------------------------------------------------


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

//alert(" modified substring = "+modified_substring)

//**********************************************************************************
// Code for Replacing five Special glyphs
//**********************************************************************************
//"æ","ç","ê","ë",
//"र्ä","र्å","र्è","र्é",    

//**********************************************************************************
// Code for Glyph1 : È (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /È/g , "Çं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".

//**********************************************************************************
// Code for Glyph2 : ç (ekAr+reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /ç/g , "Çें") ; 

//**********************************************************************************
// Code for Glyph3 : æ (ekAr+reph)
//**********************************************************************************
   modified_substring = modified_substring.replace( /æ/g , "Çे") ; 

//**********************************************************************************
// Code for Glyph4 : ë (aikAr+reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /ë/g , "Çैं") ; 

//**********************************************************************************
// Code for Glyph5 : ê (aikAr+reph)
//**********************************************************************************
   modified_substring = modified_substring.replace( /ê/g , "Çै") ; 

//**********************************************************************************
// Code for Glyph6 : Ô ( reph + ी )
//**********************************************************************************
   modified_substring = modified_substring.replace( /Ô/g , "Çी" ) ; 

//**********************************************************************************
// Code for Glyph7 : Ó ( ी + anusvAr )
//**********************************************************************************
   modified_substring = modified_substring.replace( /Ó/g , "ीं" ) ; 

//**********************************************************************************
// Code for Glyph8 : Õ ( reph + ी + anusvAr )
//**********************************************************************************
   modified_substring = modified_substring.replace( /Õ/g , "Çीं" ) ; 


//**********************************************************************************
// Code for Glyph09 : Ì  ( reph + ि )
// Code for Glyph10 : Î  (ि) [ikAr mAtrA before a संयुक्ताक्षर as in क्लिष्ट, स्थित etc)
//   replace "Ê" and "Î" with "ि" and correcting its position too(moving it one position forward)
//**********************************************************************************
   modified_substring = modified_substring.replace( /Ì/g , "र्Ê" ) ;  // at some places  Ì  is  used eg  in "धार्मिक".
   modified_substring = modified_substring.replace( /Î/g , "Ê" ) ;  

var position_of_i = modified_substring.indexOf( "Ê" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
var charecter_to_be_replaced = "Ê" + charecter_next_to_i
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
position_of_i = modified_substring.search( /Ê/ , position_of_i + 1 ) // search for i ahead of the current position.

} // end of while-02 loop

//**********************************************************************************
// Code for Glyph8 : Ë ("िं") 
// Code for Glyph9 : Í ("र्िं")
//   replace Ë with "िं"  and correcting its position too(moving it two positions forward)
//**********************************************************************************
modified_substring = modified_substring.replace( /Í/g , "र्Ë" ) ; // at some places  Í  is  used eg  in "शर्मिंदा"
modified_substring = modified_substring.replace( /Ë/g , "ÊÆ" ) ; // at some places  Ë  is  used eg  in "किंकर".

var position_of_i = modified_substring.indexOf( "ÊÆ" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_ip2 = modified_substring.charAt( position_of_i + 2 )
var charecter_to_be_replaced = "ÊÆ" + charecter_next_to_ip2
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_ip2 + "िं" ) 
position_of_i = modified_substring.search( /ÊÆ/ , position_of_i + 2 ) // search for i ahead of the current position.

} // end of while-02 loop


//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************

// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop


// Ï = "िं"  in  वेल्डिंग, कनेक्टिंग  etc
var position_of_i = modified_substring.indexOf( "Ï" )

while ( position_of_i != -1 )  //while-02
{
var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 );
var charecter_second_next_to_i = modified_substring.charAt( position_of_i + 3 );
var charecter_to_be_replaced = "Ï" + charecter_next_to_i + "्" + charecter_second_next_to_i ;

modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "्" + charecter_second_next_to_i + "िं" ) ;

position_of_i = modified_substring.search( /Ï/ , position_of_i + 2 ) // search for i ahead of the current position.

} // end of while-02 loop


//-------------------------------------------------
// Eliminating reph "Ç" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_R = modified_substring.indexOf( "Ç" )

while ( position_of_R > 0 )  // while-04
{
probable_position_of_half_r = position_of_R - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05

// following four lines added on 11-7-09
var charecter_left_to_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r - 1 )

if (charecter_left_to_probable_position_of_half_r == '्' ) 
 probable_position_of_half_r = probable_position_of_half_r - 2 ;


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_R - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "Ç" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_R = modified_substring.indexOf( "Ç" ) ;

} // end of while-04

} // end of IF  statement  meant to  supress processing of  blank  string.

   modified_substring = modified_substring.replace( /ाे/g , "ो") ; 
   modified_substring = modified_substring.replace( /ाै/g , "ौ") ; 


} // end of the function  Replace_Symbols


} // end of legacy_to_unicode function

//++++End of DV_TTSurekhEN_Unicode++//
//+++Start of ITHindi_Unicode++//

function convertITHindi_to_unicode()
{

var array_one = new Array(

"¤", "U", 

// correct anusvAr+ekAr, ekAr+nuqta to the reverse order
"¢ð","´ð","ð¸",
   
"Ò", 'Ó',  "¥æò","¸",
"¸•", "¸¹", "¸»", "¸Á","¸Ç", "¸É", "¸È","¸Ø","¸Ú","¸Ù",
 
'ö', "A","B","C","D","E","F","G","H","I","J","K","L","M",
"N","O","P","Q","R","T","V","W","X","Y",

"`","a","b","d","e","f","g","h","i","j","k","l","m","n","p","q","r","s","t","u", 'Þ', 

"žæ","ž","#","%","@",
"„","¦",  "¯","µ","º",

"Cþ", "Ê","u","g",    
"Ÿæ","Åþ","Çþ","Éþ", 
"^","h","Ð","ý","þ",

 
"¥ô","¥æð","¥õ","¥æñ","¥æ","¥","§Z","§ü","§","©","ª","«","¬","¬","°ð","°",

"€","•","","¹","‚","»","ƒæ","ƒ","¾", 
"“","‘","¿","À","”","…","’","Á",  "Û", "†æ","†",

"Å","Æ","Ç","É","‡æ","‡",
"ˆ","Ì","‰","Í","Î","¼","Š","Ï","óæ","ó","‹æ","Ù","‹",

"Œ","Â","","È","Ž","Õ","","Ö","","×",
"Ä","Ø","Ú","Ë","Ü","¶","Ý","Ã","ß",
"àæ","³æ","o","³","à","c","á","S","â","ã","±",
"ÿæ","ÿ","˜æ","˜","™æ","™","üð´",
 
"æò","æñ","æ","è","é","ê","ä","å","ë","ì","í","Ô","ñ","ô","õ",
"¢","´","¡","Ñ","¸","ò","ù","÷","ð",

"0","1","2","3","4","5","6","7","8","9",
"®","v","w","x","y","z","{","|","}","~",
"्ो","्ौ","्ाे", "्ाा","ाे","ाे","ाै","्ा","ंु","ओे","ोे","ाे","ईंं" , 'ï' )   


var array_two = new Array(

"", "",

// correct anusvAr+ekAr, ekAr+nuqta to the reverse order
"ð¢", "ð´", "¸ð",

"\'", "\'",  "ऑ", "फ़्", 
"क़","ख़","ग़","ज़","ड़","ढ़","फ़","य़","ऱ","ऩ",

'प्र',  "्र","क्च","ष्ट","ष्ठ","श्व","स्न","त्र","॥","ढ्ढ","छ्व","्य","रु","रू",
"हृ","ह्र","क्क","क्त","क्र","ञ्ज","ङ्क","ङ्ख","ङ्ग","ङ्घ",
"क्व","ड्ड","ड्ढ","स्र","द्ग","द्घ","द्द","द्ध","द्ब","द्भ","द्म","द्य","द्व","ठ्ठ","श्च", 'क्ष', "ह्म्","ह्य","ह्ल","ह्व", 'हु',
 
"त्त","त्त्","प्त","त्न","ञ्च",
"ल्ल","ष्ट्व",  "ख्न","द्ब्र","ख्र",

"ष्ट्र", "ज़्","ह्व","द्द",  
"श्र","ट्र","ड्र","ढ्र",
"ट्ट","द्ध","।","्र","्र",
 
"ओ","ओ","औ","औ","आ","अ","ईं","ई","इ","उ","ऊ","ऋ","ॠ","ऌ","ऐ","ए",

"क्", "क","ख्","ख","ग्","ग","घ","घ्","ङ",
"च्च्","च्","च","छ","ज्ज्","ज्","ज्","ज","झ", "ञ","ञ्",
 
"ट","ठ","ड","ढ","ण","ण्",
"त्","त","थ्","थ","द","द","ध्","ध","न्न","न्न्","न","न","न्",

"प्","प","फ्","फ","ब्","ब","भ्","भ","म्","म",
"य्","य","र","ल्","ल","ल","ळ","व्","व",
"श","श","श","श्","श्","ष्","ष","स्","स","ह","ह्",
"क्ष","क्ष्","त्र","त्र्","ज्ञ","ज्ञ्","ðZ",

"ॉ","ौ","ा","ी","ु","ू","ु","ू","ृ","ॄ","ॢ","े","ै","ो","ौ",
"ं","ं","ँ",":","़", "ॅ","ऽ","्","े",

"०","१","२","३","४","५","६","७","८","९",
"0","1","2","3","4","5","6","7","8","9",

"े", "ै", "े","ा","ो","ो","ौ","","ुं","ओ","ो","ो", "ईं", ''   )   



var array_one_length = array_one.length ;


if ( (document.getElementById("text_or_html")).selectedIndex == 0 )  // if the input is plain text

   { 

      document.getElementById("unitext").value = "You have chosen SIMPLE TEXT  in ITHindi font to convert into Unicode. Conversion in progress.."  ;  

      var modified_substring = document.getElementById("output").value  ;

//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = document.getElementById("output").value.length ;

    var processed_text = '' ;  //blank

    var sthiti1 = 0 ;  var sthiti2 = 0 ;  var chale_chalo = 1 ;
 
    var max_text_size = 4000;

    while ( chale_chalo == 1 ) 
    {
     sthiti1 = sthiti2 ;

     if ( sthiti2 < ( text_size - max_text_size ) )  
     { 
      sthiti2 +=  max_text_size ;
      while (document.getElementById("output").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }

     var modified_substring = document.getElementById("output").value.substring ( sthiti1, sthiti2 )  ;

    Replace_Symbols( ) ;

    processed_text += modified_substring ;

//****************************************************************************************
//  Breaking part code over
//****************************************************************************************
//
//    processed_text = processed_text.replace( /Sanskrit 99/g , "mangal" ) ;   

      document.getElementById("unitext").value = processed_text  ;

   }
}
else    // if input is HTML then
   {
    document.getElementById("unitext").value = "You have chosen HTML TEXT  in Agra font to convert into Unicode. Conversion in progress.."  ;  

    var remaining_text = document.getElementById("output").value ;
    var processed_text = "" ;  //blank initially

    var position_of_current_opening_bracket = 0 ;
    var position_of_next_closing_bracket = 1 ;

    var idx = remaining_text.indexOf( "<p " )  // search starting from paragraphs. then search for sanskrit 99.
    idx = remaining_text.indexOf( "Sanskrit 99" , idx )
    var idx2 = 0  //  position_of_current_opening_bracket  ">"
    var idx3 = 0  //  position of "/span"
    var idx4 = 0  //  postion of "span" only , ie span without "/"

    while( idx != -1 )    // while-01 loop     ;  while "Sanskrit 99"  is found..
       {  
        idx2 = remaining_text.indexOf( ">" , idx )  
        idx3 = remaining_text.indexOf( "/span" , idx2 )
        idx4 = remaining_text.indexOf( "span" , idx2 )

        while( idx4 < idx3 )     // this loop to take care of  nested span.
           {
            idx4 = remaining_text.indexOf( "span" , idx3+4 ) ;
            idx3 = remaining_text.indexOf( "/span" , idx3+4 ) ;
           }
        var modified_substring = remaining_text.substring( idx2 , idx3 ) ;
        modified_substring = modified_substring.replace( />/g , ">>" ) ; 
        processed_text = processed_text + remaining_text.substring( 0 , idx2 ) + modified_substring + "/span" ;   

        remaining_text = remaining_text.substring( idx3 + 5 ) ;  //remaining_text excludes "/span"
        idx = remaining_text.indexOf( "Sanskrit 99" ) ;
       } //end of outermost while-01
    
    processed_text = processed_text + remaining_text ;

    // -----------------------------

    //  This section for taking care of paragraphs marked class = MsoBodyText  or class = MsoBodyText

    remaining_text = processed_text ;
    processed_text = "" ;  //blank initially

    var position_of_start_of_paragraph = 0 ;
    var position_of_end_of_paragraph = 1 ;

    position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;

    while( position_of_start_of_paragraph != -1 )  //search for <p  in the remaining_text
       {
        position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;
        position_of_end_of_paragraph = remaining_text.indexOf("/p>")   ;

        modified_substring = remaining_text.substring( position_of_start_of_paragraph + 3 ,  position_of_end_of_paragraph ) ;

        if ( modified_substring.indexOf( "MsoBodyText" ) != -1 )
           { 
            modified_substring = modified_substring.replace( />/g , ">>" )  ;    // repace all ">" with ">>" in this paragraph

            idx = modified_substring.indexOf("font-family")  ;  // in Mybodytext, whereever font-family is found, it means it is roman text.
            idx2 = 0 ;  // position of ">>"
            idx3 = 0 ;  // position of "/span"
            idx4 = 0 ;  // position of "span" only without "/"

            while( idx != -1 )     // again change ">>" to ">" only those which occur immediately after font-family:"Times new Roman"
               {
                idx2 = modified_substring.indexOf( ">>" , idx ) ;
                idx3 = modified_substring.indexOf( "/span" , idx2 ) ;
                idx4 = modified_substring.indexOf( "span" , idx2 ) ;

                while( idx4 < idx3 )
                   {
                    idx4 = modified_substring.indexOf( "span" , idx3+4 )  ;
                    idx3 = modified_substring.indexOf( "/span" , idx3+4 )  ;
                   }

                modified_substring = modified_substring.substring( 0, idx2 ) + (modified_substring.substring( idx2 , idx3 )).replace( />>/g , ">" ) + modified_substring.substring( idx3 ) ; 
                idx = modified_substring.indexOf( "font-family" , idx3 ) ;

               } // end of while inner loop
            } // end of if statement

         processed_text = processed_text + remaining_text.substring( 0 , position_of_start_of_paragraph + 3 ) +  modified_substring + "/p>" ;   
         remaining_text = remaining_text.substring( position_of_end_of_paragraph + 3 ) ; 
         position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;

        } // end of outer while loop

     processed_text = processed_text + remaining_text ;

     // ------------------------

     // Now do actual font conversion  of text occuring between  all the  pairs  >>  and  <

     remaining_text = processed_text ;     processed_text = "" ; 

     idx2 = remaining_text.indexOf( ">>" )  ;

     while( idx2 != -1 )    // while-01 loop (checks if ">>" is still present
        {  
         position_of_current_opening_bracket = remaining_text.indexOf( ">>" , idx2 )  
         position_of_next_closing_bracket = remaining_text.indexOf( "<" , position_of_current_opening_bracket )

         modified_substring = remaining_text.substring( position_of_current_opening_bracket + 2 , position_of_next_closing_bracket ) ;

         processed_text = processed_text + remaining_text.substring( 0 , position_of_current_opening_bracket + 1 ) ;   // ">" included by using +1 here
         remaining_text = remaining_text.substring( position_of_next_closing_bracket + 1 ) ;  //remaining_text excludes the closing bracket

         Replace_Symbols() ;   // call the subroutine and replace the legacy symbols  with corresponding Unicode.

         processed_text = processed_text + modified_substring + "<"  ;

         idx2 = remaining_text.indexOf( ">>" ) ;

        } //end of outermost while-01

     processed_text = processed_text + remaining_text ; 

     // do follwing conversions which are still left  or  were done incorrectly due to unavoidable reasons.
 
     processed_text = processed_text.replace( /Agra/g , "mangal" ) ;   

     processed_text = processed_text.replace( /-सजय/g , "ढ" )   ;  
     processed_text = processed_text.replace( /-ुनवजय/g , "ष्" )  ;
     processed_text = processed_text.replace( /-ंउचय/g , "-" )  ;
     processed_text = processed_text.replace( /-हजय/g , "झ" )  ;
     processed_text = processed_text.replace( /-दइेचय/g , "/&nbsp" )  ; 
     processed_text = processed_text.replace( /ाॅ/g , "ॉ" )  ; 

     // now put the processed text in the output box finally.

     document.getElementById("unitext").value = processed_text  

    } // end of else loop for HTML case

 //--------------------------------------------------

 function Replace_Symbols( )
    {
     //substitute array_two elements in place of corresponding array_one elements

     if ( modified_substring != "" )  // if string to be converted is non-blank then no need of any processing.
        {

// first replace the two-byte nukta_varNa with corresponding one-byte nukta varNas.

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 , "ऱ" )  ;


         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
//**********************************************************************************
// Code for Replacing Special glyph : Z (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /Z/g , "üं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".

//=============================================================================================

// code for replacing  "ç"   with "ि" (chhotee ee kii maatraa) and correcting its position too.

var position_of_f = modified_substring.indexOf( "ç" )  ;

while ( position_of_f != -1 )  //while-02
{
var charecter_right_to_f = modified_substring.charAt( position_of_f + 1 )  ;

modified_substring = modified_substring.replace( "ç" + charecter_right_to_f  ,  charecter_right_to_f + "ि" )  ;

position_of_f = position_of_f + 1  ;

while ( ( modified_substring.charAt( position_of_f + 1 ) == "्" ) & ( position_of_f < modified_substring.length - 1 ) )
{
var string_to_be_replaced = modified_substring.charAt( position_of_f + 1 ) + modified_substring.charAt( position_of_f + 2 )  ;

modified_substring = modified_substring.replace( "ि" + string_to_be_replaced , string_to_be_replaced + "ि" )  ;

position_of_f = position_of_f + 2  ;

}

position_of_f = modified_substring.search( /ç/ , position_of_f + 1 ) ; // search for ç ahead of the current position.

} // end of while-02 loop


//======================================================================================
// code for moving "¨"  at right place and replacing it with "ç" first; and then finally replacing "ç" with "िं" (chhotee //ee kii maatraa with anuswaar) and correcting its position too.
//
var position_of_f = modified_substring.indexOf( "¨" )  ;
//
while ( position_of_f != -1 )  //while-02
{
var charecter_right_to_f = modified_substring.charAt( position_of_f + 1 )  ;

modified_substring = modified_substring.replace( "¨" + charecter_right_to_f  ,  charecter_right_to_f + "ç" )  ;


position_of_f = position_of_f + 1  ;

while (( modified_substring.charAt( position_of_f + 1 ) == "्" )  & ( position_of_f < modified_substring.length - 1 ) )
{
var string_to_be_replaced = modified_substring.charAt( position_of_f + 1 ) + modified_substring.charAt( position_of_f + 2 )  ;

modified_substring = modified_substring.replace( "ç" + string_to_be_replaced , string_to_be_replaced + "ç" )  ;

position_of_f = position_of_f + 2  ;

}

position_of_f = modified_substring.search( /¨/ , position_of_f + 1 ) ; // search for "¨" ahead of the current position.

} // end of while-02 loop

modified_substring = modified_substring.replace( /ç/g , "िं" )  ;

//======================================================================================
        //Eliminating "ü"(reph) and putting 'half - r' at proper position for this.
        set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं ः ँ ॅ" 
         var position_of_Z = modified_substring.indexOf( "ü" )

        while( position_of_Z > 0 )  // while-04
            {
             probable_position_of_half_r = position_of_Z - 1 ;
             var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )

             // trying to find non-maatra position left to current ü (ie, half -r).

             while( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05
                {
                 probable_position_of_half_r = probable_position_of_half_r - 1 ;
                 charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

                }// end of while-05

             charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_Z - probable_position_of_half_r ) ) ;
             new_replacement_string = "र्" + charecter_to_be_replaced ; 
             charecter_to_be_replaced = charecter_to_be_replaced + "ü" ;
             modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
             position_of_Z = modified_substring.indexOf( "ü" ) ;
            }// end of while-04
        }//end of IF  statement  meant to  supress processing of  blank  string.

    } // end of the function  Replace_Symbols

 } // end of legacy_to_unicode function

//++End of ITHindi_Unicode++//


//++Start of Amar_Kundli_Unicode++//
function convertAmar_to_unicode()
{

var array_one = new Array( "d", "D", "[",  "x", "X", "?", "p", "P", "N", "t",	 "T", ">", "Vª","V", "B", "M+", "Mª", "M", "<+", "<", ".",  

"r", "R", "F", "n", "/", "è", "u", "U", "iz", "i", "I", "Q", "¶", "c", "C", "H", "e", "E", ";" , '¸' , "j", 'z', "y", "Y", "o", "O",

"\'",   "\"",  "l",  "L",  "g", "º",        "J", "{", "=", "K", "}",  "#",  ":",  ")",  "Ù",  "|", "G", "Ø", "ê",

"vkS", "vks", "vk", "v", "bZ", "b", "m",  "_",  ",s", "," ,    "्k", "ks",  "kS", 'kW', "k", "h", "q", "w", "`", "s", "S", "a", "¡", "%", '~',          


"A",  "]",	 "(",  "-",   "\\",  "^^", "^",  "**", "*",  "&", '¼', '½',

"0", "1", "2", "3", "4", "5","6", "7", "8", "9"   ) ;  





var array_two = new Array( "क", "क्", "ख्", "ग",  "ग्", "घ्", "च", "च्", "छ", "ज", "ज्", "झ", "ट्र", "ट", "ठ", "ड़", "ड्र", "ड", "ढ़", "ढ", "ण्",

  		      "त", "त्", "थ्",  "द", "ध्", "ध्", "न", "न्", "प्र", "प", "प्", "फ", "फ्", "ब", "ब्", "भ्", "म", "म्", "य", "य्", "र", '्र', "ल", "ल्", "व", "व्", 

			"श्", "ष्",  "स",  "स्", "ह", 'ह्',     "श्र", "क्ष्", "त्र", "ज्ञ", "द्व", "रु", "रू", "द्ध", "त्त्", "द्य", "ळ", "क्र", "ट्ट",

        "औ", "ओ", "आ",  "अ",  "ई", "इ",  "उ",  "ऋ",   "ऐ",   "ए",       "", "ो", "ौ", 'ॉ', "ा", "ी", "ु", "ू", "ृ", "े", "ै", "ं", "ँ", ":", '्' ,                   

"।", 	",",	 ";",   ".",   "?",   '\"',  "\‘",   '\"',  "\’",   "-", '(',  ')' ,   


"०",  "१",  "२",   "३",   "४",  "५", "६",  "७",  "८",  "९" )    ;


var array_one_length = array_one.length ;

var modified_substring = document.getElementById("unitext").value  ;

Replace_Symbols( ) ;

var processed_text = modified_substring ;

processed_text = processed_text.replace( /Sanskrit 99/g , "mangal" ) ;   

document.getElementById("unitext").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 ) //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


// code for replacing "f" with "ि" (chhotee ee kii maatraa) and correcting its position too.(moving it one position forward)

modified_substring = modified_substring.replace( /£/g , "र्f" ) ;  // at some places  £  is  used eg  in "aarthik".

var position_of_f = modified_substring.indexOf( "f" )  ;

while ( position_of_f != -1 )  //while-02
{
var charecter_next_to_f = modified_substring.charAt( position_of_f + 1 )  ;
var charecter_to_be_replaced = "f" + charecter_next_to_f  ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_f + "ि" )  ;
position_of_f = modified_substring.search( /f/ , position_of_f + 1 ) ; // search for f ahead of the current position.

} // end of while-02 loop




// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop




// Eliminating "Z" and putting 'half - r' at proper position for this.
set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं : ँ ॅ" 
var position_of_Z = modified_substring.indexOf( "Z" )

while ( position_of_Z > 0 )  // while-04
{
probable_position_of_half_r = position_of_Z - 1 ;
var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )


// trying to find non-maatra position left to current O (ie, half -r).

while ( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05

{
probable_position_of_half_r = probable_position_of_half_r - 1 ;
charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

} // end of while-05


charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_Z - probable_position_of_half_r ) ) ;
new_replacement_string = "र्" + charecter_to_be_replaced ; 
charecter_to_be_replaced = charecter_to_be_replaced + "Z" ;
modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
position_of_Z = modified_substring.indexOf( "Z" ) ;

} // end of while-04

} // end of IF  statement  meant to  supress processing of  blank  string.


} // end of the function  Replace_Symbols


} // end of legacy_to_unicode function

//++End of Amar_Kundli_Unicode++//

//++Start of HTCHanakaya_Unicode++//
function convertHTChanakya_to_unicode()
{

var array_one = new Array(

// Remove the error of anusvAr+ekAr/aikAr/okAr/aukAr to ekAr/aikAr/okAr/aukAr+anusvAr

"¢ð","´ð",

"U","W","¤","ï", "¥æò",

"$X", "$¹", "$»", "Ç¸", "É¸","Èæ","Êæ","È","Ê","$Ø","$Ú","$Ù", "”¸",

"ý", "öæ","ö","#","%",
"Àþ","Þæ","Þ","Åþ","Çþ","Éþ", "º",

"Cþ","C","D","E","F","H","L","M","N","O","Q","T",
"@","^","_","a","b","d","e","g","h",

"j","k","l","m","n","p","q","ræ","r","s","t","u",
"„","†","‡","ˆ","‰","‹","‘","Ýæ","Ý","î",
"óæ","ó","öæ","ö","øæ","ø","û",

"¥æð","¥ô","¥æñ","¥õ","¥æ","¥","§Z","§ü´","§ü¢","§ü", "§","©","ª","«","¬","°ð","°Ô","°",

"X","Bæ","B","¹","Gæ","G","»", "Ræ","R","²æ","²","¾", 
"¿","¯æ","¯","À","Á",":æ","’æ",":","’","Ûæ","Û","Iæ","I",

"Å","Æ","Ç","É","Jæ","J",
"Ì","Pæ","P","Í","fæ","f","Î","¼","Ï","Væ","V","Ù","iæ","i",

"Â","`æ","`","Y","£æ","£","Õ","¦æ","¦","Ö","¬æ","¬","×","³æ","³",

"Ø","Äæ","Ä",  "Ú",  "Ü","Ëæ","¶","Ë",   "ß","Ãæ","Ã",
"àæ","o","à","á","cæ","c","â","Sæ","S",  "ã","±",
"ÿæ","ÿ","µæ","µ","½æ","½",

"&", "A","K","\\","“","–","•","Ò","Ó"," ग ",

"æò","æñ","æð","ð","æ","è","é","ê","ä","å","ë",
"Ô","ñ","ô","õ","¢´","´¢","´","¢","¡"," Ñ","Ñ","$","ò","ù","÷","Ð","ú",

"0","1","2","3","4","5","6","7","8","9",
"®","v","w","x","y","z","{","|","}","~","्ो","्ौ") ;


//	"0", "1", "2", "3", "4", "5","6", "7", "8", "9" )   ( /्k/g ,"ा" "" 

var array_two = new Array(

"ð¢","ð´",
"","","","","ऑ", 

"क़","ख़","ग़","ड़","ढ़","ज़","ज़","ज़्","ज़्","य़","ऱ","ऩ","ऴ",

"्र","त्त","त्त्","प्त","त्न",
"छ्र", "श्र","श्र्","ट्र","ड्र","ढ्र","ख्र",

"ष्ट्र","ष्ट","ष्ठ","श्व","स्न","॥","रु","रू","हृ","ह्र","क्त","ञ्ज",
"ञ्च","ट्ट","ट्ठ","ड्ड","ड्ढ","स्र","द्ग","द्द","द्ध",

"द्भ","द्म","द्य","द्व","ठ्ठ","श्च","ह्न","ह्म","ह्म्","ह्य","ह्ल","ह्व",
"ल्ल","ढ्ढ","छ्व","क्क","द्घ","द्ब","ख्न","ज्ज","ज्ज्","स्त्र",
"न्न","न्न्","त्त","त्त्","च्च","च्च्","ङ्क्त",

"ओ","ओ","औ","औ","आ","अ","ईं","ईं", "ईं","ई","इ","उ","ऊ","ऋ","ऌ","ऐ","ऐ","ए",

"क","क","क्","ख","ख","ख्","ग","ग","ग्","घ","घ्","ङ",
"च","च","च्","छ","ज","ज","ज","ज्","ज्","झ","झ्","ञ","ञ्", 

"ट","ठ","ड","ढ","ण","ण्",
"त","त","त्","थ","थ","थ्","द","द","ध","ध","ध्","न","न","न्",

"प","प","प्","फ","फ","फ्","ब","ब","ब्","भ","भ","भ्","म","म","म्",

"य","य","य्",     "र",   "ल","ल","ल","ल्",  "व","व","व्",  
"श","श","श्","ष","ष","ष्","स","स","स्",  "ह","ह्",
"क्ष","क्ष्","त्र","त्र्","ज्ञ","ज्ञ्",

"×","्न","्य","झ्र","॰","ळ्","--","‘","’"," >> ",

"ॉ","ौ","ो","े","ा","ी","ु","ू","ु","ू","ृ",
"े","ै","ो","ौ","ं","ं","ं","ं","ँ"," :","ः","़", "ॅ","ऽ","्","।","ॐ",

"०","१","२","३","४","५","६","७","८","९",
"0","1","2","3","4","5","6","7","8","9","े", "ै") ;

//   "०",  "१",  "२",   "३",   "४",  "५", "६",  "७",  "८",  "९" )

var array_one_length = array_one.length ;


if ( (document.getElementById("text_or_html")).selectedIndex == 0 )  // if the input is plain text

   { 

      document.getElementById("unitext").value = "You have chosen SIMPLE TEXT  in Chanakya font to convert into Unicode. Conversion in progress.."  ;  

      var modified_substring = document.getElementById("output").value  ;

      Replace_Symbols( ) ;

      var processed_text = modified_substring ;

      processed_text = processed_text.replace( /Sanskrit 99/g , "mangal" ) ;   

      document.getElementById("unitext").value = processed_text  ;

   }

else    // if input is HTML then
   {
    document.getElementById("unitext").value = "You have chosen HTML TEXT  in Agra font to convert into Unicode. Conversion in progress.."  ;  

    var remaining_text = document.getElementById("output").value ;
    var processed_text = "" ;  //blank initially

    var position_of_current_opening_bracket = 0 ;
    var position_of_next_closing_bracket = 1 ;

    var idx = remaining_text.indexOf( "<p " )  // search starting from paragraphs. then search for sanskrit 99.
    idx = remaining_text.indexOf( "Sanskrit 99" , idx )
    var idx2 = 0  //  position_of_current_opening_bracket  ">"
    var idx3 = 0  //  position of "/span"
    var idx4 = 0  //  postion of "span" only , ie span without "/"

    while( idx != -1 )    // while-01 loop     ;  while "Sanskrit 99"  is found..
       {  
        idx2 = remaining_text.indexOf( ">" , idx )  
        idx3 = remaining_text.indexOf( "/span" , idx2 )
        idx4 = remaining_text.indexOf( "span" , idx2 )

        while( idx4 < idx3 )     // this loop to take care of  nested span.
           {
            idx4 = remaining_text.indexOf( "span" , idx3+4 ) ;
            idx3 = remaining_text.indexOf( "/span" , idx3+4 ) ;
           }
        var modified_substring = remaining_text.substring( idx2 , idx3 ) ;
        modified_substring = modified_substring.replace( />/g , ">>" ) ; 
        processed_text = processed_text + remaining_text.substring( 0 , idx2 ) + modified_substring + "/span" ;   

        remaining_text = remaining_text.substring( idx3 + 5 ) ;  //remaining_text excludes "/span"
        idx = remaining_text.indexOf( "Sanskrit 99" ) ;
       } //end of outermost while-01
    
    processed_text = processed_text + remaining_text ;

    // -----------------------------

    //  This section for taking care of paragraphs marked class = MsoBodyText  or class = MsoBodyText

    remaining_text = processed_text ;
    processed_text = "" ;  //blank initially

    var position_of_start_of_paragraph = 0 ;
    var position_of_end_of_paragraph = 1 ;

    position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;

    while( position_of_start_of_paragraph != -1 )  //search for <p  in the remaining_text
       {
        position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;
        position_of_end_of_paragraph = remaining_text.indexOf("/p>")   ;

        modified_substring = remaining_text.substring( position_of_start_of_paragraph + 3 ,  position_of_end_of_paragraph ) ;

        if ( modified_substring.indexOf( "MsoBodyText" ) != -1 )
           { 
            modified_substring = modified_substring.replace( />/g , ">>" )  ;    // repace all ">" with ">>" in this paragraph

            idx = modified_substring.indexOf("font-family")  ;  // in Mybodytext, whereever font-family is found, it means it is roman text.
            idx2 = 0 ;  // position of ">>"
            idx3 = 0 ;  // position of "/span"
            idx4 = 0 ;  // position of "span" only without "/"

            while( idx != -1 )     // again change ">>" to ">" only those which occur immediately after font-family:"Times new Roman"
               {
                idx2 = modified_substring.indexOf( ">>" , idx ) ;
                idx3 = modified_substring.indexOf( "/span" , idx2 ) ;
                idx4 = modified_substring.indexOf( "span" , idx2 ) ;

                while( idx4 < idx3 )
                   {
                    idx4 = modified_substring.indexOf( "span" , idx3+4 )  ;
                    idx3 = modified_substring.indexOf( "/span" , idx3+4 )  ;
                   }

                modified_substring = modified_substring.substring( 0, idx2 ) + (modified_substring.substring( idx2 , idx3 )).replace( />>/g , ">" ) + modified_substring.substring( idx3 ) ; 
                idx = modified_substring.indexOf( "font-family" , idx3 ) ;

               } // end of while inner loop
            } // end of if statement

         processed_text = processed_text + remaining_text.substring( 0 , position_of_start_of_paragraph + 3 ) +  modified_substring + "/p>" ;   
         remaining_text = remaining_text.substring( position_of_end_of_paragraph + 3 ) ; 
         position_of_start_of_paragraph = remaining_text.indexOf("<p ")   ;

        } // end of outer while loop

     processed_text = processed_text + remaining_text ;

     // ------------------------

     // Now do actual font conversion  of text occuring between  all the  pairs  >>  and  <

     remaining_text = processed_text ;     processed_text = "" ; 

     idx2 = remaining_text.indexOf( ">>" )  ;

     while( idx2 != -1 )    // while-01 loop (checks if ">>" is still present
        {  
         position_of_current_opening_bracket = remaining_text.indexOf( ">>" , idx2 )  
         position_of_next_closing_bracket = remaining_text.indexOf( "<" , position_of_current_opening_bracket )

         modified_substring = remaining_text.substring( position_of_current_opening_bracket + 2 , position_of_next_closing_bracket ) ;

         processed_text = processed_text + remaining_text.substring( 0 , position_of_current_opening_bracket + 1 ) ;   // ">" included by using +1 here
         remaining_text = remaining_text.substring( position_of_next_closing_bracket + 1 ) ;  //remaining_text excludes the closing bracket

         Replace_Symbols() ;   // call the subroutine and replace the legacy symbols  with corresponding Unicode.

         processed_text = processed_text + modified_substring + "<"  ;

         idx2 = remaining_text.indexOf( ">>" ) ;

        } //end of outermost while-01

     processed_text = processed_text + remaining_text ; 

     // do follwing conversions which are still left  or  were done incorrectly due to unavoidable reasons.
 
     processed_text = processed_text.replace( /Agra/g , "mangal" ) ;   

     processed_text = processed_text.replace( /-सजय/g , "ढ" )   ;  
     processed_text = processed_text.replace( /-ुनवजय/g , "ष्" )  ;
     processed_text = processed_text.replace( /-ंउचय/g , "-" )  ;
     processed_text = processed_text.replace( /-हजय/g , "झ" )  ;
     processed_text = processed_text.replace( /-दइेचय/g , "/&nbsp" )  ; 
     processed_text = processed_text.replace( /ाॅ/g , "ॉ" )  ; 

     // now put the processed text in the output box finally.

     document.getElementById("unitext").value = processed_text  

    } // end of else loop for HTML case

 //--------------------------------------------------

 function Replace_Symbols( )
    {
     //substitute array_two elements in place of corresponding array_one elements

     if ( modified_substring != "" )  // if string to 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 ) //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


//**********************************************************************************
// Code for Replacing four Special glyphs
//**********************************************************************************
//
//**********************************************************************************
// Glyph1 : ¨ (ikAr+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /¨/g , "çं" ) ; // at some places  ì  is  used eg  in "किंकर"

//**********************************************************************************
// Glyp2: í (ikAr+reph)
//**********************************************************************************

  modified_substring = modified_substring.replace( /í/g , "र्ç" ) ;  // at some places  í  is  used eg  in "धार्मिक".

//**********************************************************************************
// Glyph3 : ì (ikAr+reph+anusvAr)
//**********************************************************************************

   modified_substring = modified_substring.replace( /ì/g , "र्çं" ) ; // at some places  ì  is  used eg  in "शर्मिंदा"

  var position_of_i = modified_substring.indexOf( "ç" )

  while ( position_of_i != -1 )  //while-02
  {
   var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
   var charecter_to_be_replaced = "ç" + charecter_next_to_i
   modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
   position_of_i = modified_substring.search( /ç/ , position_of_i + 1 ) // search for i ahead of the current position.

  } // end of while-02 loop

//**********************************************************************************
// Glyph4 : Z (reph+anusvAr)
//**********************************************************************************
   modified_substring = modified_substring.replace( /Z/g , "üं" ) ; // at some places  ì  is  used eg  in "कर्कंधु,पूर्णांक".

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************
//
// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop
//=====================
//
//**********************************************************************************
//Eliminating reph "ü" and putting 'half - r' at proper position for this.
//**********************************************************************************
        set_of_matras = "ा ि ी ु ू ृ े ै ो ौ ं ः ँ ॅ" 
         var position_of_Z = modified_substring.indexOf( "ü" )

        while( position_of_Z > 0 )  // while-04
        {
             probable_position_of_half_r = position_of_Z - 1 ;
             var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )

             // trying to find non-maatra position left to current O (ie, half -r).

             while( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05
                {
                 probable_position_of_half_r = probable_position_of_half_r - 1 ;
                 charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

                }// end of while-05

             charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_Z - probable_position_of_half_r ) ) ;
             new_replacement_string = "र्" + charecter_to_be_replaced ; 
             charecter_to_be_replaced = charecter_to_be_replaced + "ü" ;
             modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
             position_of_Z = modified_substring.indexOf( "ü" ) ;
         }// end of while-04
    }//end of IF  statement  meant to  supress processing of  blank  string.

    } // end of the function  Replace_Symbols

 } // end of legacy_to_unicode function

//++End of HTChanakya_Unicode++//
//++Start of Shaivaji_Unicode++//
function convertShivaji_to_unicode()
{

var array_one = new Array(   'iM' , '|',
"K",'#', "k","@","G", "g","=",
"C","c","J","j","H",
"z","T","Z","D", "N",
"q","t","%","Q","d", "द्", "n",
"f", "p", "P", "B","b","m",
"y","r","ळ्","l","v","S","Y", "s", "h",
'p`', "`", '\/', "x","~","&",  "V", "Ù", "E", "(", "w", "É", "$", "Ë", "W", "<", '>', '_',
"AaO", 'AÝ' , "Aao", "Aa", "A", "eo", "e", "š", "[", "ऊ", "]", "ॠ", "?",    "¸", ".",  " aa",  " a" ,
"\\", "्a", "Ý", "aO", "O", "I", "U", "u", "R", "ृ",  "ao", "o", "a", '^M' , 'M', "Á",

"³" , '\´' ,  '््' )



var array_two = new Array(  'Mi', 'ऽ',
"ख", 'ख्', "क","क्","घ्","ग्","ङ",
"छ","च्","झ्","ज्","ञ्",
"ठ","ट","ढ", "ड", "ण्",
"थ्","त","त्","ध्","द","द्","न्",
"फ", "प", "प्", "भ्", "ब्", "म्",
"य्", "र","ळ्","ल्","व्","श्","ष्","स्", "ह",
'प्र्', "्र", "्र", "क्ष्", "त्र","ज्ञ",  "द्य", "न्न", "श्र्", "ह्म", "द्ध", "रु", "रू", "क्र", "द्व", "त्त्", 'क्त', 'द्द',
"औ", "औ", "ओ", "आ", "अ","ऐ", "ए", "ई", "इ", "ऊ", "उ", "ॠ", "ऋ",    "," , "|" , " ||" ,  " |" ,
"्", "" , "ौ", "ौ", "ै", "ी", "ू", "ु", "ॄ", "ृ",  "ो",  "े", "ा", 'ँ' , 'ं',   ':' ,
'\(' , '\)', '्'  )

var array_one_length = array_one.length ;


if ( (document.getElementById("text_or_html")).selectedIndex == 0 )  // if the input is plain text

   { 

      document.getElementById("unitext").value = "You have chosen SIMPLE TEXT  in Shivaji font to convert into Unicode. Conversion in progress.."  ;  

      var modified_substring = document.getElementById("output").value  ;


//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = document.getElementById("output").value.length ;

    var processed_text = '' ;  //blank

    var sthiti1 = 0 ;  var sthiti2 = 0 ;  var chale_chalo = 1 ;
 
    var max_text_size = 6000;

    while ( chale_chalo == 1 ) 
    {
     sthiti1 = sthiti2 ;

     if ( sthiti2 < ( text_size - max_text_size ) )  
     { 
      sthiti2 +=  max_text_size ;
      while (document.getElementById("output").value.charAt ( sthiti2 ) != ' ') {sthiti2--;}
     } 
     else  { sthiti2 = text_size  ;  chale_chalo = 0 }

      modified_substring = document.getElementById("output").value.substring ( sthiti1, sthiti2 )  ;

      Replace_Symbols( ) ;

      var processed_text = processed_text + modified_substring ;

//  Breaking part code over

      document.getElementById("unitext").value = processed_text  ;

    }
   }

else    // if input is HTML then
   {
    document.getElementById("unitext").value = "You have chosen HTML TEXT  in Shivaji font to convert into Unicode. Conversion in progress.."  ;  

    var remaining_text = document.getElementById("output").value ;
    var processed_text = "" ;  //blank initially

    var position_of_current_opening_bracket = 0 ;
    var position_of_next_closing_bracket = 1 ;

    var indx = remaining_text.indexOf( "<p " )  // search starting from "<p" then search for Shivaji.
    indx = remaining_text.indexOf( "Shivaji" , indx )
    var indx2 = 0  //  position_of_current_opening_bracket  ">"
    var indx3 = 0  //  position of "/span"
    var indx4 = 0  //  postion of "span" only , ie span without "/"

    while( indx != -1 )    // while-01 loop     ;  while "Shivaji"  is found..
       {  
        indx2 = remaining_text.indexOf( ">" , indx )  
        indx3 = remaining_text.indexOf( "/span" , indx2 )
        indx4 = remaining_text.indexOf( "span" , indx2 )

        while( indx4 < indx3 )     // this loop to take care of  nested span.
           {
            indx4 = remaining_text.indexOf( "span" , indx3+4 ) ;
            indx3 = remaining_text.indexOf( "/span" , indx3+4 ) ;
           }
        var modified_substring = remaining_text.substring( indx2 , indx3 ) ;
        modified_substring = modified_substring.replace( />/g , ">>" ) ; 
        processed_text = processed_text + remaining_text.substring( 0 , indx2 ) + modified_substring + "/span" ;   

        remaining_text = remaining_text.substring( indx3 + 5 ) ;  //remaining_text excludes "/span"
        indx = remaining_text.indexOf( "Shivaji" ) ;
       } //end of outermost while-01
    
    processed_text = processed_text + remaining_text ;

    // -----------------------------

    //  This section for taking care of parShivajiphs marked class = MsoBodyText  or class = MsoBodyText

    remaining_text = processed_text ;
    processed_text = "" ;  //blank initially

    var position_of_start_of_parShivajiph = 0 ;
    var position_of_end_of_parShivajiph = 1 ;

    position_of_start_of_parShivajiph = remaining_text.indexOf("<p ")   ;

    while( position_of_start_of_parShivajiph != -1 )  //search for <p  in the remaining_text
       {
        position_of_start_of_parShivajiph = remaining_text.indexOf("<p ")   ;
        position_of_end_of_parShivajiph = remaining_text.indexOf("/p>")   ;

        modified_substring = remaining_text.substring( position_of_start_of_parShivajiph + 3 ,  position_of_end_of_parShivajiph ) ;

        if ( modified_substring.indexOf( "MsoBodyText" ) != -1 )
           { 
            modified_substring = modified_substring.replace( />/g , ">>" )  ;    // repace all ">" with ">>" in this parShivajiph

            indx = modified_substring.indexOf("font-family")  ;  // in Mybodytext, whereever font-family is found, it means it is roman text.
            indx2 = 0 ;  // position of ">>"
            indx3 = 0 ;  // position of "/span"
            indx4 = 0 ;  // position of "span" only without "/"

            while( indx != -1 )     // again change ">>" to ">" only those which occur immediately after font-family:"Times new Roman"
               {
                indx2 = modified_substring.indexOf( ">>" , indx ) ;
                indx3 = modified_substring.indexOf( "/span" , indx2 ) ;
                indx4 = modified_substring.indexOf( "span" , indx2 ) ;

                while( indx4 < indx3 )
                   {
                    indx4 = modified_substring.indexOf( "span" , indx3+4 )  ;
                    indx3 = modified_substring.indexOf( "/span" , indx3+4 )  ;
                   }

                modified_substring = modified_substring.substring( 0, indx2 ) + (modified_substring.substring( indx2 , indx3 )).replace( />>/g , ">" ) + modified_substring.substring( indx3 ) ; 
                indx = modified_substring.indexOf( "font-family" , indx3 ) ;

               } // end of while inner loop
            } // end of if statement

         processed_text = processed_text + remaining_text.substring( 0 , position_of_start_of_parShivajiph + 3 ) +  modified_substring + "/p>" ;   
         remaining_text = remaining_text.substring( position_of_end_of_parShivajiph + 3 ) ; 
         position_of_start_of_parShivajiph = remaining_text.indexOf("<p ")   ;

        } // end of outer while loop

     processed_text = processed_text + remaining_text ;

     // ------------------------

     // Now do actual font conversion  of text occuring between  all the  pairs  >>  and  <

     remaining_text = processed_text ;     processed_text = "" ; 

     indx2 = remaining_text.indexOf( ">>" )  ;

     while( indx2 != -1 )    // while-01 loop (checks if ">>" is still present
        {  
         position_of_current_opening_bracket = remaining_text.indexOf( ">>" , indx2 )  
         position_of_next_closing_bracket = remaining_text.indexOf( "<" , position_of_current_opening_bracket )

         modified_substring = remaining_text.substring( position_of_current_opening_bracket + 2 , position_of_next_closing_bracket ) ;

         processed_text = processed_text + remaining_text.substring( 0 , position_of_current_opening_bracket + 1 ) ;   // ">" included by using +1 here
         remaining_text = remaining_text.substring( position_of_next_closing_bracket + 1 ) ;  //remaining_text excludes the closing bracket



    modified_substring = modified_substring.replace( /&gt;/g , 'क्त' )   ;  
     modified_substring = modified_substring.replace( /&quot;/g , "\"" )  ;
     modified_substring = modified_substring.replace( /&lt;/g , "त्त्" )  ;
     modified_substring = modified_substring.replace( /&amp;/g , "ज्ञ" )  ;




         Replace_Symbols() ;   // call the subroutine and replace the legacy symbols  with corresponding Unicode.

         processed_text = processed_text + modified_substring + "<"  ;

         indx2 = remaining_text.indexOf( ">>" ) ;

        } //end of outermost while-01

     processed_text = processed_text + remaining_text ; 

     // do follwing conversions which are still left  or  were done incorrectly due to unavoidable reasons.
 
     processed_text = processed_text.replace( /Shivaji01/g , "mangal" ) ;   

 
     processed_text = processed_text.replace( /ज्ञन्ब्स्प;/g , "/&nbsp" )  ; 
     processed_text = processed_text.replace( /ाॅ/g , "ॉ" )  ; 

     // now put the processed text in the output box finally.

     document.getElementById("unitext").value = processed_text  

    } // end of else loop for HTML case

 //--------------------------------------------------

 function Replace_Symbols( )
    {
     //substitute array_two elements in place of corresponding array_one elements

     if ( modified_substring != "" )  // if string to 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++ )
            {
             indx = 0  ;  // index of the symbol being searched for replacement
             
             while (indx != -1 ) //whie-00
                {
                 modified_substring = modified_substring.replace( array_one[ input_symbol_idx ] , array_two[input_symbol_idx] )
                 indx = modified_substring.indexOf( array_one[input_symbol_idx] )

                } // end of while-00 loop
            } // end of for loop


//**********************************************************************************
// Code for Replacing four Special glyphs
//**********************************************************************************


  var position_of_i = modified_substring.indexOf( "i" )

  while ( position_of_i != -1 )  //while-02
  {
   var charecter_next_to_i = modified_substring.charAt( position_of_i + 1 )
   var charecter_to_be_replaced = "i" + charecter_next_to_i
   modified_substring = modified_substring.replace( charecter_to_be_replaced , charecter_next_to_i + "ि" ) 
   position_of_i = modified_substring.search( /i/ , position_of_i + 1 ) // search for i ahead of the current position.

  } // end of while-02 loop

//**********************************************************************************
// End of Code for Replacing four Special glyphs
//**********************************************************************************
//
// following loop to eliminate 'chhotee ee kee maatraa' on half-letters as a result of above transformation.

var position_of_wrong_ee = modified_substring.indexOf( "ि्" ) 

while ( position_of_wrong_ee != -1 )  //while-03

{
var consonent_next_to_wrong_ee = modified_substring.charAt( position_of_wrong_ee + 2 )
var charecter_to_be_replaced = "ि्" + consonent_next_to_wrong_ee 
modified_substring = modified_substring.replace( charecter_to_be_replaced , "्" + consonent_next_to_wrong_ee + "ि" ) 
position_of_wrong_ee = modified_substring.search( /ि्/ , position_of_wrong_ee + 2 ) // search for 'wrong ee' ahead of the current position. 

} // end of while-03 loop
//=====================
//
//**********************************************************************************
//Eliminating reph "-" and putting 'half - r' at proper position for this.
//**********************************************************************************
        set_of_matras = "ािीुूृेैोौंःँॅ" 
         var position_of_reph = modified_substring.indexOf( "-" )

        while( position_of_reph > 0 )  // while-04
        {
             probable_position_of_half_r = position_of_reph - 1 ;
             var charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r )

             // trying to find non-maatra position left to current O (ie, half -r).

             while( set_of_matras.match( charecter_at_probable_position_of_half_r ) != null )  // while-05
                {
                 probable_position_of_half_r = probable_position_of_half_r - 1 ;
                 charecter_at_probable_position_of_half_r = modified_substring.charAt( probable_position_of_half_r ) ;

                }// end of while-05

             charecter_to_be_replaced = modified_substring.substr ( probable_position_of_half_r , ( position_of_reph - probable_position_of_half_r ) ) ;
             new_replacement_string = "र्" + charecter_to_be_replaced ; 
             charecter_to_be_replaced = charecter_to_be_replaced + "-" ;
             modified_substring = modified_substring.replace( charecter_to_be_replaced , new_replacement_string ) ;
             position_of_reph = modified_substring.indexOf( "-" ) ;
         }// end of while-04
    }//end of IF  statement  meant to  supress processing of  blank  string.

    } // end of the function  Replace_Symbols

 } // end of legacy_to_unicode function

//++End of Shivaji_Unicode++//




//++Start of Yogesh_Unicode++//
// Yuvaraj font seems to be exactly like Shivaji font.

function convertYuvraj_to_unicode()
{

var array_one = new Array(   'iM' , '|',  
"K,", "K", '#,', '#',  'k,', "k",  "@,", "@",  "G", 'ga,', "g", "=",
"C", "c", "J", 'ja,', "j", "H",
"z", "T", 'Z,', "Z", 'D,', "D", "N",
"q", "t", "%", "Q", "d", "द्", "n",
'f,', "f", 'F', "p", "P", "B", "b", "m",
"y", "r", "ळ्", "l", "v", "S", "Y", "s", "h",
'E`', 'p`', " `", "`", '\/', "x", "~", "&",  "V", "Ù",  "(", "w", "É", "$", "Ë", "W", "<", '>', '_', '+',
"AaO", 'AÝ' , "Aao", "Aa^", "Aa", "A", "eo", "e", "[-", "[", "}", "]", "ॠ", "?",    "¸",  ".",  " aa",  " a" ,
"\\", "्a", "Ý", "aO", "O", "I", "U", "u", "R", "ृ",  "ao", "o", 'a^', "a", '^M' , 'M', "Á",

"³" , '\´' ,  '¹',  '््' )



var array_two = new Array(  'Mi',  'ऽ',  
'ख़', "ख",  'ख़्', 'ख्',  'क़', "क", 'क़्', "क्",  "घ्",  'ग़', "ग्",  "ङ",
"छ", "च्", "झ्", 'ज़', "ज्", "ञ्",
"ठ", "ट",  'ढ़', "ढ",  'ड़', "ड", "ण्",
"थ्", "त", "त्", "ध्", "द", "द्", "न्",
'फ़', "फ", "फ्", "प", "प्", "भ्", "ब्", "म्",
"य्", "र", "ळ्", "ल्", "व्", "श्", "ष्", "स्", "ह",
"श्र्", 'प्र्', ' ,', "्र", "्र", "क्ष्", "त्र", "ज्ञ",  "द्य", "न्न", "ह्म", "द्ध", "रु", "रू", "क्र", "द्व", "त्त्", 'क्त', 'द्द',  'ट्ट',
"औ", "औ", "ओ",  'ऑ', "आ", "अ", "ऐ", "ए", "ई", "इ", "ऊ", "उ", "ॠ", "ऋ",    "," , "|" , " ||" ,  " |" ,
"्", "" , "ौ", "ौ", "ै", "ी", "ू", "ु", "ॄ", "ृ",  "ो",  "े", 'ॉ', "ा", 'ँ' , 'ं',  ':' ,
'\(' , '\)', '-', '्'  )

var array_one_length = array_one.length ;


var modified_substring = document.getElementById("unitext").value  ;


//****************************************************************************************
//  Break the long text into small bunches of max. max_text_size  characters each.
//****************************************************************************************
    var text_size = d