Unicode to Krutidev, Krutidev to Unicode Convertor in C#






4.40/5 (5 votes)
Convertor for Unicode to Krutidev and vice-versa.
Introduction
This application is created in C# for solving major problem of Text Conversion from Unicode to Krutidev and vice-versa.
Background
When I was trying to convert Unicode to Krutidev, I could not found any offline / desktop solution for it with the source code, then I created this for the solution by using HTML page with JavaScript, which was available by Rajbhasha.net, using JavaScript for it, and using Browser control for local execution of JavaScript and Firing Event of HTML control.
Using the code
private string UnicodetoKruti(string strInput)
{
string strOutPut = "";
HtmlElementCollection theElementCollection;
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if ((curElement.GetAttribute("id").ToString() == "unicode_text"))
{
curElement.SetAttribute("Value", strInput);
}
}
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if (curElement.GetAttribute("id").Equals("converter"))
{
curElement.InvokeMember("click");
// javascript has a click method for we need to invoke on button and hyperlink elements.
}
}
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if ((curElement.GetAttribute("id").ToString() == "legacy_text"))
{
strOutPut = curElement.GetAttribute("Value");
}
}
return strOutPut;
}
//this function will convert kruti text to unicode
private string KrutitoUnicode(string strInput)
{
string strOutPut = "";
HtmlElementCollection theElementCollection;
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if ((curElement.GetAttribute("id").ToString() == "legacy_text"))
{
curElement.SetAttribute("Value", strInput);
}
}
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if (curElement.GetAttribute("id").Equals("converttounicode"))
{
curElement.InvokeMember("click");
// javascript has a click method for we need to invoke on button and
// hyperlink elements.
}
}
theElementCollection = webBrowser1.Document.GetElementsByTagName("input");
foreach (HtmlElement curElement in theElementCollection)
{
if ((curElement.GetAttribute("id").ToString() == "unicode_text"))
{
strOutPut = curElement.GetAttribute("Value");
}
}
return strOutPut;
}