Exemplo n.º 1
0
        internal static string NormalizeText(string text)
        {
            var charArray = text.ToCharArray();
            var length    = 0;
            var index     = 0;

            while (true)
            {
                for (; index >= charArray.Length || !XmlDiffView.IsWhitespace(text[index]); ++index)
                {
                    while (index < charArray.Length && !XmlDiffView.IsWhitespace(text[index]))
                    {
                        charArray[length++] = charArray[index++];
                    }
                    if (index < charArray.Length)
                    {
                        charArray[length++] = ' ';
                    }
                    else
                    {
                        if (index == 0)
                        {
                            return(string.Empty);
                        }
                        if (XmlDiffView.IsWhitespace(charArray[index - 1]))
                        {
                            --length;
                        }
                        return(new string(charArray, 0, length));
                    }
                }
                ++index;
            }
        }