65 return new byte[2] { 254, 255 };
67 return new byte[2] { 255, 254 };
129 fixed (
char* ptr =
chars)
141 fixed (
char* pChars =
s)
147 [CLSCompliant(
false)]
163 if (
s ==
null ||
bytes ==
null)
175 if (byteIndex < 0 || byteIndex >
bytes.Length)
180 fixed (
char* ptr =
s)
203 if (byteIndex < 0 || byteIndex >
bytes.Length)
212 fixed (
char* ptr =
chars)
221 [CLSCompliant(
false)]
253 fixed (
byte* ptr =
bytes)
259 [CLSCompliant(
false)]
287 if (charIndex < 0 || charIndex >
chars.Length)
296 fixed (
byte* ptr =
bytes)
305 [CLSCompliant(
false)]
337 fixed (
byte* ptr =
bytes)
339 return string.CreateStringFromEncoding(ptr +
index,
count,
this);
345 int num =
count << 1;
350 char* charStart =
chars;
377 if (num2 != 0 ||
chars < ptr)
383 ulong* ptr2 = (ulong*)(ptr - 3);
385 for (ptr3 = (ulong*)
chars; ptr3 < ptr2; ptr3++)
387 if ((0x8000800080008000uL & *ptr3) == 0
L)
391 ulong num3 = (0xF800F800F800F800uL & *ptr3) ^ 0xD800D800D800D800uL;
392 if ((num3 & 0xFFFF000000000000uL) == 0
L || (num3 & 0xFFFF00000000
L) == 0
L || (num3 & 0xFFFF0000u) == 0
L || (num3 & 0xFFFF) == 0
L)
394 long num4 = -287953294993589248
L & (long)(*ptr3);
398 if (num4 != -2593835887162763264
L)
417 if (c2 >=
'\ud800' && c2 <=
'\udfff')
425 if (encoderFallbackBuffer ==
null)
443 if (encoderFallbackBuffer ==
null)
460 if (encoderFallbackBuffer ==
null)
480 if (encoder !=
null && !encoder.
MustFlush)
488 if (encoderFallbackBuffer ==
null)
529 if (num != 0 ||
chars < ptr2)
536 ulong* ptr6 = (ulong*)
chars;
537 ulong* ptr7 = (ulong*)
bytes;
540 if ((0x8000800080008000uL & *ptr6) != 0
L)
542 ulong num2 = (0xF800F800F800F800uL & *ptr6) ^ 0xD800D800D800D800uL;
543 if ((num2 & 0xFFFF000000000000uL) == 0
L || (num2 & 0xFFFF00000000
L) == 0
L || (num2 & 0xFFFF0000u) == 0
L || (num2 & 0xFFFF) == 0
L)
545 long num3 = -287953294993589248
L & (long)(*ptr6);
549 if (num3 != -2593835887162763264
L)
555 Unsafe.WriteUnaligned(ptr7, *ptr6);
569 if (c2 >=
'\ud800' && c2 <=
'\udfff')
576 if (encoderFallbackBuffer ==
null)
594 if (encoderFallbackBuffer ==
null)
604 if (
bytes + 3 >= ptr)
606 if (encoderFallbackBuffer !=
null && encoderFallbackBuffer.
bFallingBack)
621 *(
bytes++) = (
byte)((int)c >> 8);
622 *(
bytes++) = (
byte)c;
626 *(
bytes++) = (
byte)c;
627 *(
bytes++) = (
byte)((int)c >> 8);
634 if (encoderFallbackBuffer ==
null)
649 *(
bytes++) = (
byte)((int)c2 >> 8);
650 *(
bytes++) = (
byte)c2;
654 *(
bytes++) = (
byte)c2;
655 *(
bytes++) = (
byte)((int)c2 >> 8);
659 if (encoderFallbackBuffer !=
null && encoderFallbackBuffer.
bFallingBack)
671 if (c <=
'\0' || (encoder !=
null && !encoder.
MustFlush))
679 if (encoderFallbackBuffer ==
null)
692 encoder._charLeftOver = c;
693 encoder._charsUsed = (int)(
chars - ptr4);
695 return (
int)(
bytes - ptr3);
702 byte* byteStart =
bytes;
705 int num2 =
count >> 1;
715 if (num >= 0 && (
count & 1) == 1)
724 ulong* ptr2 = (ulong*)(ptr - 7);
726 for (ptr3 = (ulong*)
bytes; ptr3 < ptr2; ptr3++)
728 if ((0x8000800080008000uL & *ptr3) == 0
L)
732 ulong num3 = (0xF800F800F800F800uL & *ptr3) ^ 0xD800D800D800D800uL;
733 if ((num3 & 0xFFFF000000000000uL) == 0
L || (num3 & 0xFFFF00000000
L) == 0
L || (num3 & 0xFFFF0000u) == 0
L || (num3 & 0xFFFF) == 0
L)
735 long num4 = -287953294993589248
L & (long)(*ptr3);
739 if (num4 != -2593835887162763264
L)
759 char c2 = ((!
bigEndian) ? ((
char)((*(
bytes++) << 8) | num)) : ((char)((num << 8) | *(
bytes++))));
761 if (c2 >=
'\ud800' && c2 <=
'\udfff')
778 if (decoderFallbackBuffer ==
null)
790 byte[] array2 =
null;
797 (byte)((
int)c2 >> 8),
800 if (decoderFallbackBuffer ==
null)
815 byte[] array3 =
null;
825 if (decoderFallbackBuffer ==
null)
834 if (decoder ==
null || decoder.
MustFlush)
839 byte[] array4 =
null;
849 if (decoderFallbackBuffer ==
null)
859 if (decoderFallbackBuffer ==
null)
895 ulong* ptr6 = (ulong*)
bytes;
896 ulong* ptr7 = (ulong*)
chars;
899 if ((0x8000800080008000uL & *ptr6) != 0
L)
901 ulong num2 = (0xF800F800F800F800uL & *ptr6) ^ 0xD800D800D800D800uL;
902 if ((num2 & 0xFFFF000000000000uL) == 0
L || (num2 & 0xFFFF00000000
L) == 0
L || (num2 & 0xFFFF0000u) == 0
L || (num2 & 0xFFFF) == 0
L)
904 long num3 = -287953294993589248
L & (long)(*ptr6);
908 if (num3 != -2593835887162763264
L)
914 Unsafe.WriteUnaligned(ptr7, *ptr6);
930 char c2 = ((!
bigEndian) ? ((
char)((*(
bytes++) << 8) | num)) : ((char)((num << 8) | *(
bytes++))));
932 if (c2 >=
'\ud800' && c2 <=
'\udfff')
948 if (decoderFallbackBuffer ==
null)
953 char* chars2 =
chars;
969 byte[] array2 =
null;
976 (byte)((
int)c2 >> 8),
979 if (decoderFallbackBuffer ==
null)
984 char* chars2 =
chars;
996 if (
chars >= ptr2 - 1)
1007 byte[] array3 =
null;
1014 (byte)((
int)c >> 8),
1017 if (decoderFallbackBuffer ==
null)
1022 char* chars2 =
chars;
1042 if (decoder ==
null || decoder.
MustFlush)
1046 byte[] array4 =
null;
1053 (byte)((
int)c >> 8),
1056 if (decoderFallbackBuffer ==
null)
1061 char* chars2 =
chars;
1084 if (decoderFallbackBuffer ==
null)
1089 char* chars2 =
chars;
1107 if (decoder !=
null)
1109 decoder._bytesUsed = (int)(
bytes - ptr3);
1110 decoder.lastChar = c;
1111 decoder.lastByte = num;
1113 return (
int)(
chars - ptr4);
1132 return new byte[2] { 255, 254 };
1134 return new byte[2] { 254, 255 };
1136 return Array.Empty<
byte>();
1146 if (base.EncoderFallback.MaxCharCount > 1)
1148 num *= base.EncoderFallback.MaxCharCount;
1151 if (num >
int.MaxValue)
1165 if (base.DecoderFallback.MaxCharCount > 1)
1167 num *= base.DecoderFallback.MaxCharCount;
1169 if (num >
int.MaxValue)
1180 if (
CodePage == unicodeEncoding.CodePage &&
byteOrderMark == unicodeEncoding.byteOrderMark &&
bigEndian == unicodeEncoding.bigEndian && base.EncoderFallback.Equals(unicodeEncoding.EncoderFallback))
1182 return base.DecoderFallback.Equals(unicodeEncoding.DecoderFallback);
static readonly bool IsLittleEndian
static string ArgumentOutOfRange_Index
static string Argument_EncoderFallbackNotEmpty
static string ArgumentOutOfRange_IndexCount
static string Argument_RecursiveFallback
static string ArgumentOutOfRange_GetCharCountOverflow
static string ArgumentOutOfRange_GetByteCountOverflow
static string Format(string resourceFormat, object p1)
static string ArgumentOutOfRange_IndexCountBuffer
static string ArgumentNull_Array
static string ArgumentOutOfRange_NeedNonNegNum
unsafe void InternalInitialize(byte *byteStart, char *charEnd)
virtual unsafe bool InternalFallback(byte[] bytes, byte *pBytes, ref char *chars)
unsafe void InternalReset()
static DecoderFallback ExceptionFallback
DecoderFallbackBuffer CreateFallbackBuffer()
new DecoderFallbackBuffer FallbackBuffer
DecoderFallbackBuffer _fallbackBuffer
bool InternalFallback(ReadOnlySpan< char > chars, out int charsConsumed)
unsafe void InternalInitialize(char *charStart, char *charEnd, EncoderNLS encoder, bool setEncoder)
char InternalGetNextChar()
EncoderFallbackBuffer CreateFallbackBuffer()
static EncoderFallback ExceptionFallback
bool InternalHasFallbackBuffer
new EncoderFallback Fallback
new EncoderFallbackBuffer FallbackBuffer
EncoderFallback encoderFallback
void ThrowBytesOverflow()
DecoderFallback decoderFallback
virtual string EncodingName
void ThrowCharsOverflow()
Decoder(UnicodeEncoding encoding)
override void SetDefaultFallbacks()
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
override byte[] GetPreamble()
unsafe override int GetCharCount(byte *bytes, int count, DecoderNLS baseDecoder)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount, DecoderNLS baseDecoder)
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount, EncoderNLS encoder)
UnicodeEncoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
unsafe override int GetByteCount(char *chars, int count, EncoderNLS encoder)
unsafe override int GetByteCount(char *chars, int count)
override ReadOnlySpan< byte > Preamble
override Encoder GetEncoder()
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
static readonly UnicodeEncoding s_littleEndianDefault
unsafe override int GetCharCount(byte *bytes, int count)
readonly bool isThrowException
override int GetHashCode()
static readonly UnicodeEncoding s_bigEndianDefault
UnicodeEncoding(bool bigEndian, bool byteOrderMark)
override int GetMaxCharCount(int byteCount)
override int GetMaxByteCount(int charCount)
override bool Equals([NotNullWhen(true)] object? value)
readonly bool byteOrderMark
unsafe override int GetByteCount(string s)
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
unsafe override int GetCharCount(byte[] bytes, int index, int count)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
override System.Text.Decoder GetDecoder()
unsafe override string GetString(byte[] bytes, int index, int count)
unsafe override int GetByteCount(char[] chars, int index, int count)
static void ThrowArgumentNullException(string name)