using UnityEngine;
using System.Collections;
//using UnityEngine.UI;
using System.Collections.Generic;
using System.IO;

public static class FarsiSaz
{

    static bool IsChasban = false;

    public static string MakeMePersianMatn(string Matn, int count)
    {
        string ConvertedMatn = "";

        string path = Application.persistentDataPath + "/temp";
        if (!Directory.Exists(path))
            Directory.CreateDirectory(path);
        path += "/1.txt";
        File.WriteAllText(path, Matn);
        string[] lines = File.ReadAllLines(path);

        for (int i = 0; i < lines.Length; i++)
        {
            string[] words = lines[i].Split(new char[] { ' ' });
            List<string> lstLines = new List<string>();

            int lineChar = 0;
            string EachLine = "";
            for (int j = 0; j < words.Length; j++)
            {
                if (lineChar + words[j].Length + 1 >= count)
                {
                    lstLines.Add(EachLine);
                    EachLine = words[j] + " ";
                    lineChar = words[j].Length + 1;
                }
                else
                {
                    EachLine += words[j] + " ";
                    lineChar += words[j].Length + 1;
                }
            }

            lstLines.Add(EachLine);

            for (int j = 0; j < lstLines.Count; j++)
            {
                ConvertedMatn += MakeMePersian(lstLines[j]) + "\n";
            }
        }


        return ConvertedMatn;
    }

    public static string MakeMePersian(string Matn)
    {
        string ConvertedMatn = "";
        string nMatn = "";
        for (int i = 0; i < Matn.Length; i++)
        {
            if (Matn[i] == '(' || Matn[i] == ')' || Matn[i] == '،' || Matn[i] == '.' || Matn[i] == '?' || Matn[i] == ':' || Matn[i] == '«' || Matn[i] == '»' || Matn[i] == '"')
            {
                nMatn += " " + Matn[i] + " ";
            }
            else
            {
                nMatn += Matn[i];
            }
        }
        Matn = nMatn;
        string[] mnt = Matn.Split(new char[] { ' ' });

        for (int i = 0; i < mnt.Length; i++)
        {
            string thisWord = "";
            string EndFatha = "";
            for (int j = 0; j < mnt[i].Length; j++)
            {
                char s = mnt[i][j];


                string word = mnt[i];

                if (word.Length > 2)
                {
                    if (CheckFatha(word[word.Length - 1]))
                    {
                        EndFatha = word[word.Length - 1].ToString();
                        mnt[i] = word.Remove(word.Length - 1);
                    }
                }

                if (mnt[i].Length == 1)
                {
                    string r = ConvertTOEnd(s);
                    thisWord += r;
                }
                else if (j == 0)
                {
                    string r = ConvertTOAval(s);
                    thisWord += r;
                }
                else if (j > 0 && j < mnt[i].Length - 1)
                {
                    string r = ConvertTOVasat(s);
                    thisWord += r;
                }
                else
                {
                    string r = ConvertTOEnd(s);
                    thisWord += r;
                }
            }
            ConvertedMatn += thisWord + EndFatha + " ";

        }

        ConvertedMatn = reverseText(ConvertedMatn);
        return ConvertedMatn;
    }

    public static string MakeMePersianNoRev(string Matn)
    {
        string ConvertedMatn = "";
        string nMatn = "";
        for (int i = 0; i < Matn.Length; i++)
        {
            if (Matn[i] == '(' || Matn[i] == ')' || Matn[i] == '،' || Matn[i] == '.' || Matn[i] == '?' || Matn[i] == ':' || Matn[i] == '«' || Matn[i] == '»' || Matn[i] == '"')
            {
                nMatn += " " + Matn[i] + " ";
            }
            else
            {
                nMatn += Matn[i];
            }
        }
        Matn = nMatn;
        string[] mnt = Matn.Split(new char[] { ' ' });

        for (int i = 0; i < mnt.Length; i++)
        {
            for (int j = 0; j < mnt[i].Length; j++)
            {
                char s = mnt[i][j];
                if (mnt[i].Length == 1)
                {
                    string r = ConvertTOEnd(s);
                    ConvertedMatn += r;
                }
                else if (j == 0)
                {
                    string r = ConvertTOAval(s);
                    ConvertedMatn += r;
                }
                else if (j > 0 && j < mnt[i].Length - 1)
                {
                    string r = ConvertTOVasat(s);
                    ConvertedMatn += r;
                }
                else
                {
                    string r = ConvertTOEnd(s);
                    ConvertedMatn += r;
                }
            }
            ConvertedMatn += " ";

        }

        //ConvertedMatn = reverseText(ConvertedMatn);
        return ConvertedMatn;
    }

    static string ConvertTOAval(char s)
    {
        string r = "";
        if (s == 'ب')
        {
            r = "ﺑ";
            IsChasban = true;
        }
        else if (s == 'ج')
        {
            r = "ﺟ";
            IsChasban = true;
        }
        else if (s == 'ث')
        {
            r = "ﺛ";
            IsChasban = true;
        }
        else if (s == 'پ')
        {
            r = "ﭘ";
            IsChasban = true;
        }
        else if (s == 'ت')
        {
            r = "ﺗ";
            IsChasban = true;
        }
        else if (s == 'خ')
        {
            r = "ﺧ";
            IsChasban = true;
        }
        else if (s == 'ح')
        {
            r = "ﺣ";
            IsChasban = true;
        }
        else if (s == 'چ')
        {
            r = "ﭼ";
            IsChasban = true;
        }
        else if (s == 'ض')
        {
            r = "ﺿ";
            IsChasban = true;
        }
        else if (s == 'ص')
        {
            r = "ﺻ";
            IsChasban = true;
        }
        else if (s == 'ش')
        {
            r = "ﺷ";
            IsChasban = true;
        }
        else if (s == 'س')
        {
            r = "ﺳ";
            IsChasban = true;
        }
        else if (s == 'غ')
        {
            r = "ﻏ";
            IsChasban = true;
        }
        else if (s == 'ع')
        {
            r = "ﻋ";
            IsChasban = true;
        }
        else if (s == 'ظ')
        {
            r = "ﻇ";
            IsChasban = true;
        }
        else if (s == 'ط')
        {
            r = "ﻃ";
            IsChasban = true;
        }
        else if (s == 'ل')
        {
            r = "ﻟ";
            IsChasban = true;
        }
        else if (s == 'ک')
        {
            r = "ﻛ";
            IsChasban = true;
        }
        else if (s == 'ك')
        {
            r = "ﻛ";
            IsChasban = true;
        }
        else if (s == 'گ')
        {
            r = "ﮔ";
            IsChasban = true;
        }
        else if (s == 'گ')
        {
            r = "ﮔ";
            IsChasban = true;
        }
        else if (s == 'ق')
        {
            r = "ﻗ";
            IsChasban = true;
        }
        else if (s == 'ف')
        {
            r = "ﻓ";
            IsChasban = true;
        }
        else if (s == 'ه')
        {
            r = "ﻫ";
            IsChasban = true;
        }
        else if (s == 'ن')
        {
            r = "ﻧ";
            IsChasban = true;
        }
        else if (s == 'ی')
        {
            r = "ﻳ";
            IsChasban = true;
        }
        else if (s == 'ي')
        {
            r = "ﻳ";
            IsChasban = true;
        }
        else if (s == 'م')
        {
            r = "ﻣ";
            IsChasban = true;
        }
        else if (s == 'ئ')
        {
            r = "ﺋ";
            IsChasban = true;
        }
        else
        {
            r = s.ToString();
            if (CheckFatha(s))
            {

            }
            else
            {
                IsChasban = false;
            }
        }
        return r;

    }

    static string ConvertTOVasat(char s)
    {
        string r = "";
        if (s == 'ا')
        {
            if (!IsChasban)
            {
                r = "ﺍ";
                IsChasban = false;
            }
            else
            {
                r = ConvertTOEnd(s);
            }
        }
        else if (s == 'ب')
        {
            if (IsChasban)
            {
                r = "ﺒ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'پ')
        {
            if (IsChasban)
            {
                r = "ﭙ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ج')
        {
            if (IsChasban)
            {
                r = "ﺠ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'چ')
        {
            if (IsChasban)
            {
                r = "ﭽ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ث')
        {
            if (IsChasban)
            {
                r = "ﺜ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ت')
        {
            if (IsChasban)
            {
                r = "ﺘ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ز')
        {
            if (IsChasban)
            {
                r = "ﺰ";
            }
            else
            {
                r = "ز";
            }
            IsChasban = false;
        }
        else if (s == 'ر')
        {
            if (IsChasban)
            {
                r = "ﺮ";
            }
            else
            {
                r = "ر";
            }
            IsChasban = false;
        }
        else if (s == 'ژ')
        {
            if (IsChasban)
            {
                r = "ﮋ";
            }
            else
            {
                r = "ژ";
            }
            IsChasban = false;
        }
        else if (s == 'ذ')
        {
            if (IsChasban)
            {
                r = "ﺬ";
            }
            else
            {
                r = "ذ";
            }
            IsChasban = false;
        }
        else if (s == 'د')
        {
            if (IsChasban)
            {
                r = "ﺪ";
            }
            else
            {
                r = "د";
            }
            IsChasban = false;
        }
        else if (s == 'گ')
        {
            if (IsChasban)
            {
                r = "ﮕ";
            }
            else
            {
                r = "ﮔ";
            }
            IsChasban = true;
        }
        else if (s == 'خ')
        {
            if (IsChasban)
            {
                r = "ﺨ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ح')
        {
            if (IsChasban)
            {
                r = "ﺤ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ض')
        {
            if (IsChasban)
            {
                r = "ﻀ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ص')
        {
            if (IsChasban)
            {
                r = "ﺼ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ش')
        {
            if (IsChasban)
            {
                r = "ﺸ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'س')
        {
            if (IsChasban)
            {
                r = "ﺴ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'غ')
        {
            if (IsChasban)
            {
                r = "ﻐ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ع')
        {
            if (IsChasban)
            {
                r = "ﻌ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ظ')
        {
            if (IsChasban)
            {
                r = "ﻈ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ط')
        {
            if (IsChasban)
            {
                r = "ﻄ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ل')
        {
            if (IsChasban)
            {
                r = "ﻠ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ك')
        {
            if (IsChasban)
            {
                r = "ﻜ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ک')
        {
            if (IsChasban)
            {
                r = "ﻜ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ق')
        {
            if (IsChasban)
            {
                r = "ﻘ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ف')
        {
            if (IsChasban)
            {
                r = "ﻔ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ی')
        {
            if (IsChasban)
            {
                r = "ﻴ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ي')
        {
            if (IsChasban)
            {
                r = "ﻴ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'و')
        {
            if (IsChasban)
            {
                r = "ﻮ";
                IsChasban = false;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ه')
        {
            if (IsChasban)
            {
                r = "ﻬ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ن')
        {
            if (IsChasban)
            {
                r = "ﻨ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'م')
        {
            if (IsChasban)
            {
                r = "ﻤ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else if (s == 'ئ')
        {
            if (IsChasban)
            {
                r = "ﺌ";
                IsChasban = true;
            }
            else
            {
                r = ConvertTOAval(s);
            }
        }
        else
        {
            r = s.ToString();
            if (CheckFatha(s))
            {

            }
            else
            {
                IsChasban = false;
            }
        }
        return r;
    }

    static string ConvertTOEnd(char s)
    {
        string r = "";
        if (s == 'ا')
        {
            if (IsChasban)
            {
                r = "ﺎ";
            }
            else
            {
                r = "ا";
            }
            IsChasban = false;
        }
        else if (s == 'ب')
        {
            if (IsChasban)
            {
                r = "ﺐ";
            }
            else
            {
                r = "ب";
            }
            IsChasban = false;
        }
        else if (s == 'ج')
        {
            if (IsChasban)
            {
                r = "ﺞ";
            }
            else
            {
                r = "ج";
            }
            IsChasban = false;
        }
        else if (s == 'چ')
        {
            if (IsChasban)
            {
                r = "ﭻ";
            }
            else
            {
                r = "چ";
            }
            IsChasban = false;
        }
        else if (s == 'ث')
        {
            if (IsChasban)
            {
                r = "ﺚ";
            }
            else
            {
                r = "ث";
            }
            IsChasban = false;
        }
        else if (s == 'ت')
        {
            if (IsChasban)
            {
                r = "ﺖ";
            }
            else
            {
                r = "ت";
            }
            IsChasban = false;
        }
        else if (s == 'پ')
        {
            if (IsChasban)
            {
                r = "ﭗ";
            }
            else
            {
                r = "پ";
            }
            IsChasban = false;
        }
        else if (s == 'ز')
        {
            if (IsChasban)
            {
                r = "ﺰ";
            }
            else
            {
                r = "ز";
            }
            IsChasban = false;
        }
        else if (s == 'ر')
        {
            if (IsChasban)
            {
                r = "ﺮ";
            }
            else
            {
                r = "ر";
            }
            IsChasban = false;
        }
        else if (s == 'ژ')
        {
            if (IsChasban)
            {
                r = "ﮋ";
            }
            else
            {
                r = "ژ";
            }
            IsChasban = false;
        }
        else if (s == 'ذ')
        {
            if (IsChasban)
            {
                r = "ﺬ";
            }
            else
            {
                r = "ذ";
            }
            IsChasban = false;
        }
        else if (s == 'د')
        {
            if (IsChasban)
            {
                r = "ﺪ";
            }
            else
            {
                r = "د";
            }
            IsChasban = false;
        }
        else if (s == 'خ')
        {
            if (IsChasban)
            {
                r = "ﺦ";
            }
            else
            {
                r = "خ";
            }
            IsChasban = false;
        }
        else if (s == 'گ')
        {
            if (IsChasban)
            {
                r = "ﮓ";
            }
            else
            {
                r = "گ";
            }
            IsChasban = false;
        }
        else if (s == 'خ')
        {
            if (IsChasban)
            {
                r = "ﺦ";
            }
            else
            {
                r = "خ";
            }
            IsChasban = false;
        }
        else if (s == 'ح')
        {
            if (IsChasban)
            {
                r = "ﺢ";
            }
            else
            {
                r = "ح";
            }
            IsChasban = false;
        }
        else if (s == 'ض')
        {
            if (IsChasban)
            {
                r = "ﺾ";
            }
            else
            {
                r = "ض";
            }
            IsChasban = false;
        }
        else if (s == 'ص')
        {
            if (IsChasban)
            {
                r = "ﺺ";
            }
            else
            {
                r = "ص";
            }
            IsChasban = false;
        }
        else if (s == 'ش')
        {
            if (IsChasban)
            {
                r = "ﺶ";
            }
            else
            {
                r = "ش";
            }
            IsChasban = false;
        }
        else if (s == 'س')
        {
            if (IsChasban)
            {
                r = "ﺲ";
            }
            else
            {
                r = "س";
            }
            IsChasban = false;
        }
        else if (s == 'غ')
        {
            //Debug.Log("s");
            if (IsChasban)
            {
                r = "ﻎ";
            }
            else
            {
                r = "غ";
            }
            IsChasban = false;
        }
        else if (s == 'ع')
        {
            if (IsChasban)
            {
                r = "ﻊ";
            }
            else
            {
                r = "ع";
            }
            IsChasban = false;
        }
        else if (s == 'ظ')
        {
            if (IsChasban)
            {
                r = "ﻆ";
            }
            else
            {
                r = "ظ";
            }
            IsChasban = false;
        }
        else if (s == 'ط')
        {
            if (IsChasban)
            {
                r = "ﻂ";
            }
            else
            {
                r = "ط";
            }
            IsChasban = false;
        }
        else if (s == 'ل')
        {
            if (IsChasban)
            {
                r = "ﻞ";
            }
            else
            {
                r = "ل";
            }
            IsChasban = false;
        }
        else if (s == 'ك')
        {
            if (IsChasban)
            {
                r = "ﻚ";
            }
            else
            {
                r = "ک";
            }
            IsChasban = false;
        }
        else if (s == 'ک')
        {
            if (IsChasban)
            {
                r = "ﻚ";
            }
            else
            {
                r = "ک";
            }
            IsChasban = false;
        }
        else if (s == 'ق')
        {
            if (IsChasban)
            {
                r = "ﻖ";
            }
            else
            {
                r = "ق";
            }
            IsChasban = false;
        }
        else if (s == 'ف')
        {
            if (IsChasban)
            {
                r = "ﻒ";
            }
            else
            {
                r = "ف";
            }
            IsChasban = false;
        }
        else if (s == 'ی')
        {
            if (IsChasban)
            {
                r = "ﻰ";
            }
            else
            {
                r = "ی";
            }
            IsChasban = false;
        }
        else if (s == 'ي')
        {
            if (IsChasban)
            {
                r = "ﻰ";

            }
            else
            {
                r = "ی";
            }
            IsChasban = false;
        }
        else if (s == 'و')
        {
            if (IsChasban)
            {
                r = "ﻮ";
            }
            else
            {
                r = "و";
            }
            IsChasban = false;
        }
        else if (s == 'ه')
        {
            if (IsChasban)
            {
                r = "ﻪ";
            }
            else
            {
                r = "ه";
            }
            IsChasban = false;
        }
        else if (s == 'ن')
        {
            if (IsChasban)
            {
                r = "ﻦ";
            }
            else
            {
                r = "ن";
            }
            IsChasban = false;
        }
        else if (s == 'م')
        {
            if (IsChasban)
            {
                r = "ﻢ";
            }
            else
            {
                r = "م";
            }
            IsChasban = false;
        }
        else if (s == 'ئ')
        {
            if (IsChasban)
            {
                r = "ﺊ";
            }
            else
            {
                r = "ﺉ";
            }
            IsChasban = false;
        }
        else
        {
            if (CheckFatha(s))
            {

            }
            else
            {
                IsChasban = false;
            }
            r = s.ToString();

        }
        return r;
    }

    static public string reverseText(string Matn)
    {
        Matn = ChangeNOFaToNoEng(Matn);
        string rMatn = "";
        for (int i = Matn.Length - 1; i >= 0; i--)
        {
            rMatn += Matn[i];
        }

        string[] words = rMatn.Split(new char[] { ' ' });
        int x = 0;
        for (int i = 0; i < words.Length; i++)
        {
            if (int.TryParse(words[i].ToLower(), out x))
            {
                string s = "";
                for (int j = words[i].Length - 1; j >= 0; j--)
                {
                    s += words[i][j];
                }
                words[i] = s;
            }
            else if (words[i].ToLower().Contains("a") || words[i].ToLower().Contains("b") || words[i].ToLower().Contains("c") || words[i].ToLower().Contains("d") || words[i].ToLower().Contains("e") || words[i].ToLower().Contains("f") || words[i].ToLower().Contains("g") || words[i].ToLower().Contains("h") || words[i].ToLower().Contains("i") || words[i].ToLower().Contains("j") || words[i].ToLower().Contains("k") || words[i].ToLower().Contains("l") || words[i].ToLower().Contains("m") || words[i].ToLower().Contains("n") || words[i].ToLower().Contains("o") || words[i].ToLower().Contains("p") || words[i].ToLower().Contains("q") || words[i].ToLower().Contains("r") || words[i].ToLower().Contains("s") || words[i].ToLower().Contains("t") || words[i].ToLower().Contains("u") || words[i].ToLower().Contains("v") || words[i].ToLower().Contains("w") || words[i].ToLower().Contains("x") || words[i].ToLower().Contains("y") || words[i].ToLower().Contains("z") || words[i].ToLower().Contains("0") || words[i].ToLower().Contains("1") || words[i].ToLower().Contains("2") || words[i].ToLower().Contains("3") || words[i].ToLower().Contains("4") || words[i].ToLower().Contains("5") || words[i].ToLower().Contains("6") || words[i].ToLower().Contains("7") || words[i].ToLower().Contains("8") || words[i].ToLower().Contains("9"))
            {
                //Debug.Log(words[i]);
                string s = "";
                for (int j = words[i].Length - 1; j >= 0; j--)
                {
                    s += words[i][j];
                }
                words[i] = s;
            }
            else if (words[i].Trim() == ")")
            {
                words[i] = "(";
            }
            else if (words[i].Trim() == "(")
            {
                words[i] = ")";
            }
            else if (words[i].Trim() == "«")
            {
                words[i] = "»";
            }
            else if (words[i].Trim() == "»")
            {
                words[i] = "«";
            }
        }
        rMatn = "";
        for (int i = 0; i < words.Length; i++)
        {
            rMatn += words[i] + " ";
        }
        //rMatn = ChangeNOEngToNoFA(rMatn);
        return rMatn;
    }

    static public string ChangeNOFaToNoEng(string matn)
    {
        string s = matn;
        s = s.Replace('١', '1');
        s = s.Replace('٢', '2');
        s = s.Replace('٣', '3');
        s = s.Replace('٤', '4');
        s = s.Replace('٥', '5');
        s = s.Replace('٦', '6');
        s = s.Replace('٧', '7');
        s = s.Replace('٨', '8');
        s = s.Replace('٩', '9');
        s = s.Replace('٠', '0');
        return s;
    }

    static public string ChangeNOEngToNoFA(string matn)
    {
        string s = matn;
        s = s.Replace('1', '١');
        s = s.Replace('2', '٢');
        s = s.Replace('3', '٣');
        s = s.Replace('4', '٤');
        s = s.Replace('5', '٥');
        s = s.Replace('6', '٦');
        s = s.Replace('7', '٧');
        s = s.Replace('8', '٨');
        s = s.Replace('9', '٩');
        s = s.Replace('0', '٠');
        return s;
    }

    static bool CheckFatha(char s)
    {
        //string r = "";
        if (s == 'ا')
        {
            return false;
        }
        else if (s == 'ب')
        {
            return false;
        }
        else if (s == 'ج')
        {
            return false;

        }
        else if (s == 'ث')
        {
            return false;

        }
        else if (s == 'پ')
        {
            return false;

        }
        else if (s == 'ت')
        {
            return false;

        }
        else if (s == 'خ')
        {
            return false;

        }
        else if (s == 'ح')
        {
            return false;

        }
        else if (s == 'چ')
        {
            return false;

        }
        else if (s == 'ض')
        {
            return false;

        }
        else if (s == 'ص')
        {
            return false;

        }
        else if (s == 'ش')
        {
            return false;

        }
        else if (s == 'س')
        {
            return false;

        }
        else if (s == 'غ')
        {
            return false;

        }
        else if (s == 'ع')
        {
            return false;

        }
        else if (s == 'ظ')
        {
            return false;

        }
        else if (s == 'ط')
        {
            return false;

        }
        else if (s == 'ل')
        {
            return false;

        }
        else if (s == 'ک')
        {
            return false;

        }
        else if (s == 'ك')
        {
            return false;

        }
        else if (s == 'گ')
        {
            return false;

        }
        else if (s == 'گ')
        {
            return false;

        }
        else if (s == 'ق')
        {
            return false;

        }
        else if (s == 'ف')
        {
            return false;

        }
        else if (s == 'ه')
        {
            return false;

        }
        else if (s == 'ن')
        {
            return false;

        }
        else if (s == 'ی')
        {
            return false;

        }
        else if (s == 'ي')
        {
            return false;

        }
        else if (s == 'م')
        {
            return false;


        }
        else if (s == 'ئ')
        {
            return false;

        }
        else if (s == 'ز')
        {
            return false;

        }
        else if (s == 'ر')
        {
            return false;

        }
        else if (s == 'ژ')
        {
            return false;

        }
        else if (s == 'ذ')
        {
            return false;

        }
        else if (s == 'د')
        {
            return false;
        }
        else if (s == 'و')
        {
            return false;
        }
        else if (s.ToString().ToLower().Contains("a") || s.ToString().ToLower().Contains("b") || s.ToString().ToLower().Contains("c") || s.ToString().ToLower().Contains("d") || s.ToString().ToLower().Contains("e") || s.ToString().ToLower().Contains("f") || s.ToString().ToLower().Contains("g") || s.ToString().ToLower().Contains("h") || s.ToString().ToLower().Contains("i") || s.ToString().ToLower().Contains("j") || s.ToString().ToLower().Contains("k") || s.ToString().ToLower().Contains("l") || s.ToString().ToLower().Contains("m") || s.ToString().ToLower().Contains("n") || s.ToString().ToLower().Contains("o") || s.ToString().ToLower().Contains("p") || s.ToString().ToLower().Contains("q") || s.ToString().ToLower().Contains("r") || s.ToString().ToLower().Contains("s") || s.ToString().ToLower().Contains("t") || s.ToString().ToLower().Contains("u") || s.ToString().ToLower().Contains("v") || s.ToString().ToLower().Contains("w") || s.ToString().ToLower().Contains("x") || s.ToString().ToLower().Contains("y") || s.ToString().ToLower().Contains("z") || s.ToString().ToLower().Contains("0") || s.ToString().ToLower().Contains("1") || s.ToString().ToLower().Contains("2") || s.ToString().ToLower().Contains("3") || s.ToString().ToLower().Contains("4") || s.ToString().ToLower().Contains("5") || s.ToString().ToLower().Contains("6") || s.ToString().ToLower().Contains("7") || s.ToString().ToLower().Contains("8") || s.ToString().ToLower().Contains("9"))
        {
            return false;
        }

        return true;
    }

    static bool CheckChasban(char s)
    {
        if (s == 'ا')
        {
            return false;
        }
        else if (s == 'ز')
        {
            return false;
        }
        else if (s == 'ر')
        {
            return false;
        }
        else if (s == 'ژ')
        {
            return false;
        }
        else if (s == 'ذ')
        {
            return false;
        }
        else if (s == 'د')
        {
            return false;
        }
        else if (s == 'و')
        {
            return false;
        }

        return true;
    }


    public static string AproximateVal(int val)
    {
        if (val < 100)
        {
            return val.ToString();
        }
        else if (val >= 100 && val < 1000)
        {
            return "100+";
        }
        else if (val >= 1000 && val < 1000000)
        {
            int x = val / 1000;

            return x.ToString() + "K";
        }
        else
        {
            int x = val / 1000000;
            return x.ToString() + "M";
        }
    }
}
