GetUnescapeSequence() private static method

private static GetUnescapeSequence ( string str, int index, int &newIndex ) : string
str string
index int
newIndex int
return string
Example #1
0
        private static string Unescape(string str)
        {
            if (str == null)
            {
                return(null);
            }
            StringBuilder stringBuilder = null;
            int           length        = str.Length;
            int           num           = 0;

            while (true)
            {
                int num2 = str.IndexOf('&', num);
                if (num2 == -1)
                {
                    break;
                }
                if (stringBuilder == null)
                {
                    stringBuilder = new StringBuilder();
                }
                stringBuilder.Append(str, num, num2 - num);
                stringBuilder.Append(SecurityElement.GetUnescapeSequence(str, num2, out num));
            }
            if (stringBuilder == null)
            {
                return(str);
            }
            stringBuilder.Append(str, num, length - num);
            return(stringBuilder.ToString());
        }
Example #2
0
        private static string Unescape(string str)
        {
            if (str == null)
            {
                return((string)null);
            }
            StringBuilder stringBuilder = (StringBuilder)null;
            int           length        = str.Length;
            int           newIndex      = 0;

            while (true)
            {
                int index = str.IndexOf('&', newIndex);
                if (index != -1)
                {
                    if (stringBuilder == null)
                    {
                        stringBuilder = new StringBuilder();
                    }
                    stringBuilder.Append(str, newIndex, index - newIndex);
                    stringBuilder.Append(SecurityElement.GetUnescapeSequence(str, index, out newIndex));
                }
                else
                {
                    break;
                }
            }
            if (stringBuilder == null)
            {
                return(str);
            }
            stringBuilder.Append(str, newIndex, length - newIndex);
            return(stringBuilder.ToString());
        }