150 if (
bytes.Length != 1)
172 [Obsolete(
"The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.", DiagnosticId =
"SYSLIB0001", UrlFormat =
"https://aka.ms/dotnet-warnings/{0}")]
174 : this(allowOptionals: false)
178 [Obsolete(
"The UTF-7 encoding is insecure and should not be used. Consider using UTF-8 instead.", DiagnosticId =
"SYSLIB0001", UrlFormat =
"https://aka.ms/dotnet-warnings/{0}")]
186 [MemberNotNull(
"_base64Bytes")]
187 [MemberNotNull(
"_base64Values")]
188 [MemberNotNull(
"_directEncode")]
192 for (
int i = 0; i < 64; i++)
194 _base64Bytes[i] = (byte)
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[i];
197 for (
int j = 0; j < 128; j++)
201 for (
int k = 0; k < 64; k++)
206 int length =
"\t\n\r '(),-./0123456789:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".Length;
207 for (
int l = 0; l <
length; l++)
209 _directEncode[(uint)
"\t\n\r '(),-./0123456789:?ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"[l]] =
true;
213 length =
"!\"#$%&*;<=>@[]^_`{|}".Length;
214 for (
int m = 0; m <
length; m++)
231 if (
_allowOptionals == uTF7Encoding._allowOptionals && base.EncoderFallback.Equals(uTF7Encoding.EncoderFallback))
233 return base.DecoderFallback.Equals(uTF7Encoding.DecoderFallback);
242 return CodePage + base.EncoderFallback.GetHashCode() + base.DecoderFallback.GetHashCode();
263 fixed (
char* ptr =
chars)
275 fixed (
char* pChars =
s)
281 [CLSCompliant(
false)]
297 if (
s ==
null ||
bytes ==
null)
309 if (byteIndex < 0 || byteIndex >
bytes.Length)
314 fixed (
char* ptr =
s)
337 if (byteIndex < 0 || byteIndex >
bytes.Length)
346 fixed (
char* ptr =
chars)
355 [CLSCompliant(
false)]
387 fixed (
byte* ptr =
bytes)
393 [CLSCompliant(
false)]
421 if (charIndex < 0 || charIndex >
chars.Length)
430 fixed (
byte* ptr =
bytes)
439 [CLSCompliant(
false)]
471 fixed (
byte* ptr =
bytes)
473 return string.CreateStringFromEncoding(ptr +
index,
count,
this);
516 if (!encodingByteBuffer.
AddByte(45))
522 if (!encodingByteBuffer.
AddByte((
byte)nextChar))
528 if (num2 < 0 && nextChar ==
'+')
530 if (!encodingByteBuffer.
AddByte((
byte)43, (
byte)45))
538 if (!encodingByteBuffer.
AddByte(43))
544 num = (num << 16) | nextChar;
561 if (num2 >= 0 && (encoder ==
null || encoder.
MustFlush))
567 if (encodingByteBuffer.
AddByte(45))
577 if (
bytes !=
null && encoder !=
null)
580 encoder.bitCount = num2;
581 encoder._charsUsed = encodingByteBuffer.
CharsUsed;
583 return encodingByteBuffer.
Count;
606 if (!encodingCharBuffer.
AddChar((
char)((uint)(num >> num2 - 16) & 0xFFFFu)))
622 num = (num << 6) | (
byte)b;
628 num3 = (num >> num2 - 16) & 0xFFFF;
636 if (!encodingCharBuffer.
Fallback(nextByte))
659 if (!encodingCharBuffer.
Fallback(nextByte))
667 if (num3 >= 0 && !encodingCharBuffer.
AddChar((
char)num3))
677 if (
chars !=
null && decoder !=
null)
682 decoder.bitCount = -1;
683 decoder.firstByte =
false;
688 decoder.bitCount = num2;
689 decoder.firstByte = flag;
691 decoder._bytesUsed = encodingCharBuffer.
BytesUsed;
693 return encodingCharBuffer.
Count;
713 if (num >
int.MaxValue)
static string ArgumentOutOfRange_Index
static string Argument_InvalidCharSequenceNoIndex
static string ArgumentOutOfRange_IndexCount
static string ArgumentOutOfRange_GetByteCountOverflow
static string ArgumentOutOfRange_IndexCountBuffer
static string ArgumentNull_Array
static string ArgumentOutOfRange_NeedNonNegNum
DecoderFallbackBuffer _fallbackBuffer
EncoderFallbackBuffer _fallbackBuffer
unsafe bool AddByte(byte b, int moreBytesExpected)
unsafe char GetNextChar()
unsafe byte GetNextByte()
unsafe bool AddChar(char ch, int numBytes)
bool Fallback(byte fallbackByte)
unsafe void AdjustBytes(int count)
EncoderFallback encoderFallback
void ThrowBytesOverflow()
DecoderFallback decoderFallback
void ThrowCharsOverflow()
override bool MovePrevious()
unsafe override int InternalFallback(byte[] bytes, byte *pBytes)
unsafe override void Reset()
override char GetNextChar()
override bool Fallback(byte[] bytesUnknown, int index)
override DecoderFallbackBuffer CreateFallbackBuffer()
override int GetHashCode()
override bool Equals([NotNullWhen(true)] object value)
override int MaxCharCount
Decoder(UTF7Encoding encoding)
Encoder(UTF7Encoding encoding)
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount, DecoderNLS baseDecoder)
override void SetDefaultFallbacks()
override System.Text.Decoder GetDecoder()
unsafe override int GetByteCount(string s)
unsafe override int GetCharCount(byte *bytes, int count, DecoderNLS baseDecoder)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
unsafe override int GetCharCount(byte[] bytes, int index, int count)
readonly bool _allowOptionals
override bool Equals([NotNullWhen(true)] object? value)
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
UTF7Encoding(bool allowOptionals)
override System.Text.Encoder GetEncoder()
override int GetMaxCharCount(int byteCount)
unsafe override int GetByteCount(char[] chars, int index, int count)
unsafe override int GetByteCount(char *chars, int count)
static readonly UTF7Encoding s_default
unsafe override int GetCharCount(byte *bytes, int count)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount, EncoderNLS baseEncoder)
unsafe override int GetByteCount(char *chars, int count, EncoderNLS baseEncoder)
override int GetHashCode()
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
unsafe override string GetString(byte[] bytes, int index, int count)
override int GetMaxByteCount(int charCount)
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
static void ThrowArgumentNullException(string name)