Beispiel #1
0
        static private string BoldSearchedWords(string showText, SearchWords searchWords)
        {
            string result = "";

            bool   atWord           = false;
            string currentWord      = "";
            string currentOutOfWord = "";
            int    count            = showText.Length;

            for (int i = 0; i < count; i++)
            {
                char c = WebIndex.Normalize(showText[i]);
                if (WebIndex.GoodChar(c))
                {
                    if (!atWord)
                    {
                        currentWord = "";
                        atWord      = true;
                        result     += HttpUtility.HtmlEncode(currentOutOfWord);
                    }
                    currentWord += c;
                }
                else
                {
                    if (atWord)
                    {
                        currentOutOfWord = "";
                        atWord           = false;
                        result          += FormatSearchWord(currentWord, searchWords);
                    }
                    currentOutOfWord += c;
                }
            }
            if (atWord)
            {
                result += FormatSearchWord(currentWord, searchWords);
            }
            else
            {
                result += HttpUtility.HtmlEncode(currentOutOfWord);
            }

            return(result);
        }