Exemplo n.º 1
0
        // Token: 0x06000256 RID: 598 RVA: 0x0000B710 File Offset: 0x00009910
        private static void CalculateMethodAndChunkSize_Utf8(bool allowQEncoding, ByteEncoder.Tables.CharClasses unsafeCharClassesForQEncoding, Encoding encoding, string value, int valueOffset, int encodedWordSpace, out byte method, out int chunkSize)
        {
            int  num   = encodedWordSpace / 4 * 3;
            int  num2  = 0;
            int  num3  = 0;
            int  num4  = 0;
            int  num5  = 0;
            int  num6  = valueOffset;
            bool flag  = false;
            bool flag2 = false;

            while (num6 != value.Length && (!flag || !flag2))
            {
                int  num7 = 1;
                int  num8 = 1;
                int  num9 = 1;
                char c    = value[num6++];
                if (MimeCommon.QEncodingRequired(c, unsafeCharClassesForQEncoding))
                {
                    if (c > '\u007f')
                    {
                        num9++;
                        if (c > '߿')
                        {
                            num9++;
                            if (MimeCommon.IsAnySurrogate(c) && MimeCommon.IsHighSurrogate(c) && num6 != value.Length && MimeCommon.IsLowSurrogate(value[num6]))
                            {
                                num6++;
                                num7++;
                                num9++;
                            }
                        }
                    }
                    num8 = num9 * 3;
                }
                flag  = (flag || num5 + num9 > num);
                flag2 = (flag2 || num3 + num8 > encodedWordSpace);
                if (!flag)
                {
                    num5 += num9;
                    num4 += num7;
                }
                if (!flag2)
                {
                    num3 += num8;
                    num2 += num7;
                }
            }
            if (num2 >= num4 && num3 < num5 + 3)
            {
                chunkSize = num2;
                method    = 81;
                return;
            }
            chunkSize = MimeCommon.AdjustChunkSize(encoding, num4, value, valueOffset, num);
            method    = 66;
        }