// Token: 0x0600025A RID: 602 RVA: 0x0000B9AC File Offset: 0x00009BAC private static int AdjustChunkSize(Encoding encoding, int chunkSize, string value, int valueOffset, int targetBytes) { int i = MimeCommon.GetByteCount(encoding, value, valueOffset, chunkSize); if (i > targetBytes) { int num = chunkSize * targetBytes / i; if (num < chunkSize) { if (MimeCommon.IsLowSurrogate(value[valueOffset + num]) && MimeCommon.IsHighSurrogate(value[valueOffset + num - 1])) { num--; } chunkSize = num; i = MimeCommon.GetByteCount(encoding, value, valueOffset, chunkSize); } while (i > targetBytes) { num = chunkSize * targetBytes / i; if (num < chunkSize) { chunkSize = num; } else { chunkSize--; } if (MimeCommon.IsLowSurrogate(value[valueOffset + chunkSize]) && MimeCommon.IsHighSurrogate(value[valueOffset + chunkSize - 1])) { chunkSize--; } i = MimeCommon.GetByteCount(encoding, value, valueOffset, chunkSize); } } if (i < targetBytes - 2 && i != 0) { int num2 = 0; while (valueOffset + chunkSize < value.Length && num2++ < 3) { int num3 = 1; if (MimeCommon.IsHighSurrogate(value[valueOffset + chunkSize]) && valueOffset + chunkSize + 1 < value.Length && MimeCommon.IsLowSurrogate(value[valueOffset + chunkSize + 1])) { num3++; } i = MimeCommon.GetByteCount(encoding, value, valueOffset, chunkSize + num3); if (i > targetBytes) { break; } chunkSize += num3; } } return(chunkSize); }