コード例 #1
0
        internal static string UrlDecodeInternal(byte[] bytes, int offset, int count, Encoding encoding)
        {
            StringBuilder stringBuilder = new StringBuilder();
            MemoryStream  memoryStream  = new MemoryStream();
            int           num           = count + offset;
            int           i             = offset;

            while (i < num)
            {
                if (bytes[i] != 37 || i + 2 >= count || bytes[i + 1] == 37)
                {
                    goto IL_C6;
                }
                if (bytes[i + 1] == 117 && i + 5 < num)
                {
                    if (memoryStream.Length > 0L)
                    {
                        stringBuilder.Append(HttpUtility.GetChars(memoryStream, encoding));
                        memoryStream.SetLength(0L);
                    }
                    int @char = HttpUtility.GetChar(bytes, i + 2, 4);
                    if (@char == -1)
                    {
                        goto IL_C6;
                    }
                    stringBuilder.Append((char)@char);
                    i += 5;
                }
                else
                {
                    int @char;
                    if ((@char = HttpUtility.GetChar(bytes, i + 1, 2)) == -1)
                    {
                        goto IL_C6;
                    }
                    memoryStream.WriteByte((byte)@char);
                    i += 2;
                }
IL_10E:
                i++;
                continue;
IL_C6:
                if (memoryStream.Length > 0L)
                {
                    stringBuilder.Append(HttpUtility.GetChars(memoryStream, encoding));
                    memoryStream.SetLength(0L);
                }
                if (bytes[i] == 43)
                {
                    stringBuilder.Append(' ');
                    goto IL_10E;
                }
                stringBuilder.Append((char)bytes[i]);
                goto IL_10E;
            }
            if (memoryStream.Length > 0L)
            {
                stringBuilder.Append(HttpUtility.GetChars(memoryStream, encoding));
            }
            return(stringBuilder.ToString());
        }