Esempio n. 1
0
        private static bool UnescapeChar(string input, ref int lastSavedIndex, int loopEndIndex, int rdnEndIndex, ref int currentIndex, bool acceptEscapedSpace, ref StringBuilder sbConversion)
        {
            for (;;)
            {
                if (input[currentIndex] == '\\')
                {
                    int  num = currentIndex;
                    char c   = input[++currentIndex];
                    char value;
                    if (AdName.IsEscapedChar(c))
                    {
                        value = c;
                    }
                    else
                    {
                        char hexChar = input[++currentIndex];
                        int  num2;
                        if (!AdName.TryConvertHexPairToNumber(c, hexChar, out num2))
                        {
                            break;
                        }
                        value = (char)num2;
                    }
                    if (sbConversion == null)
                    {
                        sbConversion = new StringBuilder(input, lastSavedIndex, num - lastSavedIndex, rdnEndIndex - lastSavedIndex);
                    }
                    else
                    {
                        sbConversion.Append(input, lastSavedIndex, num - lastSavedIndex);
                    }
                    sbConversion.Append(value);
                    lastSavedIndex = currentIndex + 1;
                }
                if (++currentIndex >= loopEndIndex)
                {
                    goto Block_4;
                }
            }
            return(false);

Block_4:
            currentIndex--;
            return(true);
        }
Esempio n. 2
0
        private static bool TryFormatChar(string input, ref int lastSavedIndex, int loopEndIndex, int rdnEndIndex, ref int currentIndex, bool acceptEscapedSpace, bool needEscapeSpace, ref StringBuilder sbConversion)
        {
            for (;;)
            {
                int  num  = currentIndex;
                bool flag = false;
                char c2;
                if (input[currentIndex] == '\\')
                {
                    if (currentIndex + 1 >= rdnEndIndex)
                    {
                        break;
                    }
                    char c = input[++currentIndex];
                    if (!AdName.IsFormattedChar(c))
                    {
                        if (c == '\r' || c == '\n')
                        {
                            c2 = c;
                            goto IL_EC;
                        }
                        if (c == ' ')
                        {
                            if (!acceptEscapedSpace)
                            {
                                return(false);
                            }
                            if (!needEscapeSpace)
                            {
                                c2 = c;
                                goto IL_EC;
                            }
                        }
                        else
                        {
                            if (currentIndex + 1 >= rdnEndIndex)
                            {
                                return(false);
                            }
                            char hexChar = input[++currentIndex];
                            int  num2;
                            if (!AdName.TryConvertHexPairToNumber(c, hexChar, out num2))
                            {
                                return(false);
                            }
                            if (num2 != 10 && num2 != 13)
                            {
                                c2   = (char)num2;
                                flag = (AdName.IsFormattedChar(c2) || (c2 == ' ' && needEscapeSpace));
                                goto IL_EC;
                            }
                        }
                    }
                }
                else if (AdName.IsEscapedChar(input[currentIndex]))
                {
                    if (input[currentIndex] != ' ')
                    {
                        return(false);
                    }
                    if (needEscapeSpace)
                    {
                        flag = true;
                        c2   = ' ';
                        goto IL_EC;
                    }
                }
IL_138:
                if (++currentIndex >= loopEndIndex)
                {
                    goto Block_18;
                }
                continue;
IL_EC:
                if (sbConversion == null)
                {
                    sbConversion = new StringBuilder(input, lastSavedIndex, num - lastSavedIndex, rdnEndIndex - lastSavedIndex);
                }
                else
                {
                    sbConversion.Append(input, lastSavedIndex, num - lastSavedIndex);
                }
                if (flag)
                {
                    sbConversion.Append("\\");
                }
                sbConversion.Append(c2);
                lastSavedIndex = currentIndex + 1;
                goto IL_138;
            }
            return(false);

Block_18:
            currentIndex--;
            return(true);
        }