コード例 #1
0
 public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
 {
     ArabicFixerTool.showTashkeel    = showTashkeel;
     ArabicFixerTool.useHinduNumbers = useHinduNumbers;
     if (str.Contains("\n"))
     {
         str = str.Replace("\n", Environment.NewLine);
     }
     if (str.Contains(Environment.NewLine))
     {
         string[] separator = new string[] { Environment.NewLine };
         string[] strArray2 = str.Split(separator, StringSplitOptions.None);
         if (strArray2.Length == 0)
         {
             return(ArabicFixerTool.FixLine(str));
         }
         if (strArray2.Length == 1)
         {
             return(ArabicFixerTool.FixLine(str));
         }
         string str2  = ArabicFixerTool.FixLine(strArray2[0]);
         int    index = 1;
         if (strArray2.Length > 1)
         {
             while (index < strArray2.Length)
             {
                 str2 = str2 + Environment.NewLine + ArabicFixerTool.FixLine(strArray2[index]);
                 index++;
             }
         }
         return(str2);
     }
     return(ArabicFixerTool.FixLine(str));
 }
コード例 #2
0
        /// <summary>
        /// Fix the specified string with customization options.
        /// </summary>
        /// <param name='str'>
        /// String to be fixed.
        /// </param>
        /// <param name='showTashkeel'>
        /// Show tashkeel.
        /// </param>
        /// <param name='useHinduNumbers'>
        /// Use hindu numbers.
        /// </param>
        public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
        {
            ArabicFixerTool.showTashkeel    = showTashkeel;
            ArabicFixerTool.useHinduNumbers = useHinduNumbers;

            str = str.Replace("\n", Environment.NewLine);

            if (!str.Contains(Environment.NewLine))
            {
                return(ArabicFixerTool.FixLine(str));
            }

            string[] stringSeparators = new string[] { Environment.NewLine };
            string[] strSplit         = str.Split(stringSeparators, StringSplitOptions.None);

            switch (strSplit.Length)
            {
            case 0:
            case 1:
                return(ArabicFixerTool.FixLine(str));

            default:
                StringBuilder outputString = new StringBuilder(ArabicFixerTool.FixLine(strSplit[0]));
                for (int iteration = 1; iteration < strSplit.Length; iteration++)
                {
                    outputString.Append(Environment.NewLine + ArabicFixerTool.FixLine(strSplit[iteration]));
                }

                return(outputString.ToString());
            }
        }
コード例 #3
0
        /// <summary>
        /// Fix the specified string with customization options.
        /// </summary>
        /// <param name='str'>
        /// String to be fixed.
        /// </param>
        /// <param name='showTashkeel'>
        /// Show tashkeel.
        /// </param>
        /// <param name='useHinduNumbers'>
        /// Use hindu numbers.
        /// </param>
        public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
        {
            ArabicFixerTool.showTashkeel    = showTashkeel;
            ArabicFixerTool.useHinduNumbers = useHinduNumbers;

            if (str.IsNullOrEmpty())
            {
                return("");
            }

            if (str.Contains("\n"))
            {
                str = str.Replace("\n", Environment.NewLine);
            }

            if (str.Contains(Environment.NewLine))
            {
                string[] stringSeparators = new string[] { Environment.NewLine };
                string[] strSplit         = str.Split(stringSeparators, StringSplitOptions.None);

                if (strSplit.Length == 0)
                {
                    return(ArabicFixerTool.FixLine(str));
                }
                else if (strSplit.Length == 1)
                {
                    return(ArabicFixerTool.FixLine(str));
                }
                else
                {
                    string outputString = ArabicFixerTool.FixLine(strSplit[0]);
                    int    iteration    = 1;
                    if (strSplit.Length > 1)
                    {
                        while (iteration < strSplit.Length)
                        {
                            outputString += Environment.NewLine + ArabicFixerTool.FixLine(strSplit[iteration]);
                            iteration++;
                        }
                    }
                    return(outputString);
                }
            }
            else
            {
                return(ArabicFixerTool.FixLine(str));
            }
        }
コード例 #4
0
        /// <summary>
        /// Fix the specified string with customization options.
        /// </summary>
        /// <param name='str'>
        /// String to be fixed.
        /// </param>
        /// <param name='showTashkeel'>
        /// Show tashkeel.
        /// </param>
        /// <param name='useHinduNumbers'>
        /// Use hindu numbers.
        /// </param>
        public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
        {
            ArabicFixerTool.showTashkeel    = showTashkeel;
            ArabicFixerTool.useHinduNumbers = useHinduNumbers;

            if (str.Contains("\n"))
            {
                str = str.Replace("\n", "\r\n");
            }

            if (str.Contains("\r\n"))
            {
                string[] stringSeparators = { "\r\n" };
                string[] strSplit         = str.Split(stringSeparators, StringSplitOptions.None);

                if (strSplit.Length == 0)
                {
                    return(ArabicFixerTool.FixLine(str));
                }
                else if (strSplit.Length == 1)
                {
                    return(ArabicFixerTool.FixLine(str));
                }
                else
                {
                    var outputString = ArabicFixerTool.FixLine(strSplit[0]);
                    var iteration    = 1;
                    if (strSplit.Length <= 1)
                    {
                        return(outputString);
                    }
                    while (iteration < strSplit.Length)
                    {
                        outputString += "\r\n" + ArabicFixerTool.FixLine(strSplit[iteration]);
                        iteration++;
                    }
                    return(outputString);
                }
            }

            return(ArabicFixerTool.FixLine(str));
        }