Krutidev To Unicode Convert Your text from krutidev to unicode Tool Script

Certainly! Here's a Python script that can convert text from KrutiDev to Unicode:

Krutidev To Unicode Convert Your text from krutidev to unicode Tool  Script

Krutidev To Unicode Convert Your text from krutidev to unicode Tool  Script 

# -*- coding: utf-8 -*-

from flask import Flask, render_template, request

app = Flask(__name__)

kruti_unicode_map = {
    # KrutiDev to Unicode mapping dictionary
    u"क": u"\u0915", u"ख": u"\u0916", u"ग": u"\u0917", u"घ": u"\u0918", u"ङ": u"\u0919",
    u"च": u"\u091a", u"छ": u"\u091b", u"ज": u"\u091c", u"झ": u"\u091d", u"ञ": u"\u091e",
    u"ट": u"\u091f", u"ठ": u"\u0920", u"ड": u"\u0921", u"ढ": u"\u0922", u"ण": u"\u0923",
    u"त": u"\u0924", u"थ": u"\u0925", u"द": u"\u0926", u"ध": u"\u0927", u"न": u"\u0928",
    u"प": u"\u092a", u"फ": u"\u092b", u"ब": u"\u092c", u"भ": u"\u092d", u"म": u"\u092e",
    u"य": u"\u092f", u"र": u"\u0930", u"ल": u"\u0932", u"व": u"\u0935", u"श": u"\u0936",
    u"ष": u"\u0937", u"स": u"\u0938", u"ह": u"\u0939", u"क़": u"\u0958", u"ख़": u"\u0959",
    u"ग़": u"\u095a", u"ज़": u"\u095b", u"ड़": u"\u095c", u"ढ़": u"\u095d", u"फ़": u"\u095e",
    u"य़": u"\u095f", u"ऑ": u"\u0959", u"आ": u"\u0906", u"ई": u"\u0908", u"ऊ": u"\u090a",
    u"ए": u"\u090f", u"ऐ": u"\u0910", u"ओ": u"\u0913", u"औ": u"\u0914", u"ा": u"\u093e",
    u"ि": u"\u093f", u"ी": u"\u0940", u"ु": u"\u0941", u"ू": u"\u0942", u"े": u"\u0947",
    u"ै": u"\u0948", u"ो": u"\u094b", u"ौ": u"\u094c", u"ं": u"\u0902", u"ः": u"\u0903",
    u"ॅ": u"\u0945", u"ऽ": u"\u093d", u"्": u"\u094d", u"०": u"\u0966", u"१": u"\u0967",
    u"२": u"\u0968", u"३": u"\u0969", u"४": u"\u096a", u"५": u"\u096b", u"६": u"\u096c",
    u"७": u"\u096d", u"८": u"\u096e", u"९": u"\u096f", u"ऋ": u"\u0943", u"ॠ": u"\u0944",
    u"ऌ": u"\u0943", u"ॡ": u"\u0944", u"ॐ": u"\u0950", u"क़": u"\u0958", u"ख़": u"\u0959",
    u"ग़": u"\u095a", u"ज़": u"\u095b", u"ड़": u"\u095c", u"ढ़": u"\u095d", u"फ़": u"\u095e",
    u"य़": u"\u095f"
}

def krutidev_to_unicode(text):
    converted_text = ""
    for char in text:
        if char in kruti_unicode_map:
            converted_text += kruti_unicode_map[char]
        else:
            converted_text += char
    return converted_text

def unicode_to_krutidev(text):
    reverse_map = {v: k for k, v in kruti_unicode_map.items()}
    converted_text = ""
    for char in text:
        if char in reverse_map:
            converted_text += reverse_map[char]
        else:
            converted_text += char
    return converted_text

@app.route("/", methods=["GET", "POST"])
def convert_text():
    if request.method == "POST":
        text = request.form["text"]
        conversion_type = request.form["conversion_type"]

        if conversion_type == "krutidev_to_unicode":
            converted_text = krutidev_to_unicode(text)
        elif conversion_type == "unicode_to_krutidev":
            converted_text = unicode_to_krutidev(text)
        else:
            converted_text = ""

        return render_template("index.html", converted_text=converted_text, text=text, conversion_type=conversion_type)

    return render_template("index.html")

if __name__ == "__main__":
    app.run(debug=True)


This updated script uses the Flask framework to create a web application. It includes an HTML template (index.html) where users can enter the text and select the conversion type (Krutidev to Unicode or Unicode to Krutidev). The converted text is displayed on the same page.

To run the script, make sure Flask is installed (pip install flask) and run the script in your Python environment. Access the web application in your browser by visiting http://localhost:5000.

You'll also need to create an index.html file in the same directory as the script. Here's an example template you can use:


<!DOCTYPE html>
<html>
<head>
    <title>Krutidev to Unicode Converter</title>
    <style>
        body {
            font-family: Arial, sans-serif;
        }
        h1 {
            text-align: center;
        }
        .container {
            margin: 50px auto;
            width: 400px;
        }
        label {
            display: block;
            margin-bottom: 10px;
        }
        textarea {
            width: 100%;
            height: 100px;
            resize: vertical;
        }
        select {
            width: 100%;
            margin-bottom: 10px;
        }
        input[type="submit"] {
            display: block;
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            cursor: pointer;
        }
        .converted-text {
            margin-top: 20px;
        }
    </style>
</head>
<body>
    <h1>Krutidev to Unicode Converter</h1>
    <div class="container">
        <form method="post" action="/">
            <label for="text">Text:</label>
            <textarea id="text" name="text" placeholder="Enter text..." required>{{ text }}</textarea>
            <label for="conversion_type">Conversion Type:</label>
            <select id="conversion_type" name="conversion_type">
                <option value="krutidev_to_unicode" {% if conversion_type == "krutidev_to_unicode" %}selected{% endif %}>Krutidev to Unicode</option>
                <option value="unicode_to_krutidev" {% if conversion_type == "unicode_to_krutidev" %}selected{% endif %}>Unicode to Krutidev</option>
            </select>
            <input type="submit" value="Convert">
        </form>
        {% if converted_text %}
            <div class="converted-text">
                <h3>Converted Text:</h3>
                <textarea readonly>{{ converted_text }}</textarea>
            </div>
        {% endif %}
    </div>
</body>
</html>


Save the above HTML code in a file named index.html in the same directory as the script.

Post a Comment

0 Comments