Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / WinForms

Unicode to Krutidev, Krutidev to Unicode Convertor in C#

4.40/5 (5 votes)
14 Oct 2012CPOL 132.8K   2.4K  
Convertor for Unicode to Krutidev and vice-versa.

Image 1

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.

Unicode_to_Krutidev/krutitounicode.JPG

Unicode_to_Krutidev/unicodetokruti.JPG

Unicode_to_Krutidev/loadshtmlinbrowsercontrol.JPG

Using the code

C#
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;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)