10 [__DynamicallyInvokable]
16 internal int lastByte = -1;
18 internal char lastChar;
20 internal override bool HasState
26 return lastChar !=
'\0';
43 lastByte = (int)info.GetValue(
"lastByte", typeof(
int));
47 lastChar = (char)info.GetValue(
"lastChar", typeof(
char));
52 bool bigEndian = (bool)info.GetValue(
"bigEndian", typeof(
bool));
64 info.AddValue(
"m_encoding", m_encoding);
65 info.AddValue(
"m_fallback", m_fallback);
66 info.AddValue(
"lastChar", lastChar);
67 info.AddValue(
"lastByte", lastByte);
71 public override void Reset()
75 if (m_fallbackBuffer !=
null)
77 m_fallbackBuffer.Reset();
82 [OptionalField(VersionAdded = 2)]
83 internal bool isThrowException;
85 internal bool bigEndian;
87 internal bool byteOrderMark =
true;
93 [__DynamicallyInvokable]
95 : this(bigEndian: false, byteOrderMark: true)
104 [__DynamicallyInvokable]
106 : this(bigEndian, byteOrderMark, throwOnInvalidBytes: false)
117 [__DynamicallyInvokable]
119 : base(bigEndian ? 1201 : 1200)
121 isThrowException = throwOnInvalidBytes;
122 this.bigEndian = bigEndian;
123 this.byteOrderMark = byteOrderMark;
124 if (isThrowException)
126 SetDefaultFallbacks();
133 isThrowException =
false;
136 internal override void SetDefaultFallbacks()
138 if (isThrowException)
145 encoderFallback =
new EncoderReplacementFallback(
"�");
146 decoderFallback =
new DecoderReplacementFallback(
"�");
163 [SecuritySafeCritical]
164 [__DynamicallyInvokable]
165 public unsafe
override int GetByteCount(
char[] chars,
int index,
int count)
171 if (index < 0 || count < 0)
175 if (chars.Length - index < count)
179 if (chars.Length == 0)
183 fixed (
char* ptr = chars)
198 [SecuritySafeCritical]
199 [__DynamicallyInvokable]
206 fixed (
char* chars = s)
224 [CLSCompliant(
false)]
257 [SecuritySafeCritical]
258 [__DynamicallyInvokable]
259 public unsafe
override int GetBytes(
string s,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
261 if (s ==
null || bytes ==
null)
265 if (charIndex < 0 || charCount < 0)
269 if (s.Length - charIndex < charCount)
273 if (byteIndex < 0 || byteIndex > bytes.Length)
277 int byteCount = bytes.Length - byteIndex;
278 if (bytes.Length == 0)
282 fixed (
char* ptr = s)
284 byte[] array = bytes;
285 fixed (
byte* ptr2 = array)
287 return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount,
null);
310 [SecuritySafeCritical]
311 [__DynamicallyInvokable]
312 public unsafe
override int GetBytes(
char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
314 if (chars ==
null || bytes ==
null)
318 if (charIndex < 0 || charCount < 0)
322 if (chars.Length - charIndex < charCount)
326 if (byteIndex < 0 || byteIndex > bytes.Length)
330 if (chars.Length == 0)
334 int byteCount = bytes.Length - byteIndex;
335 if (bytes.Length == 0)
339 fixed (
char* ptr = chars)
341 byte[] array = bytes;
342 fixed (
byte* ptr2 = array)
344 return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount,
null);
365 [CLSCompliant(
false)]
367 public unsafe
override int GetBytes(
char* chars,
int charCount,
byte* bytes,
int byteCount)
369 if (bytes ==
null || chars ==
null)
373 if (charCount < 0 || byteCount < 0)
377 return GetBytes(chars, charCount, bytes, byteCount,
null);
393 [SecuritySafeCritical]
394 [__DynamicallyInvokable]
395 public unsafe
override int GetCharCount(
byte[] bytes,
int index,
int count)
401 if (index < 0 || count < 0)
405 if (bytes.Length - index < count)
409 if (bytes.Length == 0)
413 fixed (
byte* ptr = bytes)
431 [CLSCompliant(
false)]
464 [SecuritySafeCritical]
465 [__DynamicallyInvokable]
466 public unsafe
override int GetChars(
byte[] bytes,
int byteIndex,
int byteCount,
char[] chars,
int charIndex)
468 if (bytes ==
null || chars ==
null)
472 if (byteIndex < 0 || byteCount < 0)
476 if (bytes.Length - byteIndex < byteCount)
480 if (charIndex < 0 || charIndex > chars.Length)
484 if (bytes.Length == 0)
488 int charCount = chars.Length - charIndex;
489 if (chars.Length == 0)
493 fixed (
byte* ptr = bytes)
495 char[] array = chars;
496 fixed (
char* ptr2 = array)
498 return GetChars(ptr + byteIndex, byteCount, ptr2 + charIndex, charCount,
null);
519 [CLSCompliant(
false)]
521 public unsafe
override int GetChars(
byte* bytes,
int byteCount,
char* chars,
int charCount)
523 if (bytes ==
null || chars ==
null)
527 if (charCount < 0 || byteCount < 0)
531 return GetChars(bytes, byteCount, chars, charCount,
null);
547 [SecuritySafeCritical]
549 [__DynamicallyInvokable]
550 public unsafe
override string GetString(
byte[] bytes,
int index,
int count)
556 if (index < 0 || count < 0)
560 if (bytes.Length - index < count)
564 if (bytes.Length == 0)
568 fixed (
byte* ptr = bytes)
570 return string.CreateStringFromEncoding(ptr + index, count,
this);
575 internal unsafe
override int GetByteCount(
char* chars,
int count, EncoderNLS encoder)
577 int num = count << 1;
582 char* charStart = chars;
583 char* ptr = chars + count;
586 ulong* ptr2 = (ulong*)(ptr - 3);
587 EncoderFallbackBuffer encoderFallbackBuffer =
null;
590 c = encoder.charLeftOver;
595 if (encoder.InternalHasFallbackBuffer)
597 encoderFallbackBuffer = encoder.FallbackBuffer;
598 if (encoderFallbackBuffer.Remaining > 0)
600 throw new ArgumentException(Environment.GetResourceString(
"Argument_EncoderFallbackNotEmpty",
EncodingName, encoder.Fallback.GetType()));
602 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder:
false);
607 char num2 = encoderFallbackBuffer?.InternalGetNextChar() ??
'\0';
609 if (num2 != 0 || chars < ptr)
613 if (!bigEndian && c ==
'\0' && ((
long)chars & 7) == 0L)
616 for (ptr3 = (ulong*)chars; ptr3 < ptr2; ptr3++)
618 if ((-9223231297218904064L & (
long)(*ptr3)) != 0L)
620 ulong num3 = (ulong)((-576188069258921984L & (
long)(*ptr3)) ^ -2882066263381583872
L);
621 if ((((
long)num3 & -281474976710656L) == 0L || (num3 & 0xFFFF00000000) == 0L || (num3 & 4294901760u) == 0L || (num3 & 0xFFFF) == 0L) && ((-287953294993589248
L & (long)(*ptr3)) ^ -2593835887162763264L) != 0
L)
640 if (c2 >=
'\ud800' && c2 <=
'\udfff')
648 if (encoderFallbackBuffer ==
null)
650 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
651 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder:
false);
653 encoderFallbackBuffer.InternalFallback(c, ref chars);
664 if (encoderFallbackBuffer ==
null)
666 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
667 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder:
false);
669 encoderFallbackBuffer.InternalFallback(c2, ref chars);
679 if (encoderFallbackBuffer ==
null)
681 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
682 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder:
false);
684 encoderFallbackBuffer.InternalFallback(c, ref chars);
697 if (encoder !=
null && !encoder.MustFlush)
703 throw new ArgumentException(Environment.GetResourceString(
"Argument_RecursiveFallback", c),
"chars");
705 if (encoderFallbackBuffer ==
null)
707 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
708 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder:
false);
710 encoderFallbackBuffer.InternalFallback(c, ref chars);
718 internal unsafe
override int GetBytes(
char* chars,
int charCount,
byte* bytes,
int byteCount, EncoderNLS encoder)
722 byte* ptr = bytes + byteCount;
723 char* ptr2 = chars + charCount;
726 EncoderFallbackBuffer encoderFallbackBuffer =
null;
729 c = encoder.charLeftOver;
730 if (encoder.InternalHasFallbackBuffer)
732 encoderFallbackBuffer = encoder.FallbackBuffer;
733 if (encoderFallbackBuffer.Remaining > 0 && encoder.m_throwOnOverflow)
735 throw new ArgumentException(Environment.GetResourceString(
"Argument_EncoderFallbackNotEmpty",
EncodingName, encoder.Fallback.GetType()));
737 encoderFallbackBuffer.InternalInitialize(ptr4, ptr2, encoder, setEncoder:
false);
742 char num = encoderFallbackBuffer?.InternalGetNextChar() ??
'\0';
744 if (num != 0 || chars < ptr2)
748 if (!bigEndian && ((
long)chars & 7) == 0L && ((
long)bytes & 7) == 0L && c ==
'\0')
750 ulong* ptr5 = (ulong*)(chars - 3 + ((ptr - bytes >> 1 < ptr2 - chars) ? (ptr - bytes >> 1) : (ptr2 - chars)));
751 ulong* ptr6 = (ulong*)chars;
752 ulong* ptr7 = (ulong*)bytes;
755 if ((-9223231297218904064L & (
long)(*ptr6)) != 0L)
757 ulong num2 = (ulong)((-576188069258921984L & (
long)(*ptr6)) ^ -2882066263381583872L);
758 if ((((
long)num2 & -281474976710656
L) == 0L || (num2 & 0xFFFF00000000) == 0
L || (num2 & 4294901760u) == 0L || (num2 & 0xFFFF) == 0
L) && ((-287953294993589248L & (
long)(*ptr6)) ^ -2593835887162763264L) != 0
L)
774 else if (c ==
'\0' && !bigEndian && ((
long)chars & 7) != ((
long)bytes & 7) && ((
int)bytes & 1) == 0)
776 long num3 = (ptr - bytes >> 1 < ptr2 - chars) ? (ptr - bytes >> 1) : (ptr2 - chars);
777 char* ptr8 = (
char*)bytes;
778 char* ptr9 = chars + num3 - 1;
781 if (*chars >=
'\ud800' && *chars <=
'\udfff')
783 if (*chars >=
'\udc00' || chars[1] <
'\udc00' || chars[1] >
'\udfff')
788 else if (chars[1] >=
'\ud800' && chars[1] <=
'\udfff')
809 if (c2 >=
'\ud800' && c2 <=
'\udfff')
816 if (encoderFallbackBuffer ==
null)
818 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
819 encoderFallbackBuffer.InternalInitialize(ptr4, ptr2, encoder, setEncoder:
true);
821 encoderFallbackBuffer.InternalFallback(c, ref chars);
832 if (encoderFallbackBuffer ==
null)
834 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
835 encoderFallbackBuffer.InternalInitialize(ptr4, ptr2, encoder, setEncoder:
true);
837 encoderFallbackBuffer.InternalFallback(c2, ref chars);
840 if (bytes + 3 >= ptr)
842 if (encoderFallbackBuffer !=
null && encoderFallbackBuffer.bFallingBack)
844 encoderFallbackBuffer.MovePrevious();
845 encoderFallbackBuffer.MovePrevious();
851 ThrowBytesOverflow(encoder, bytes == ptr3);
857 byte* intPtr = bytes;
859 *intPtr = (byte)((
int)c >> 8);
860 byte* intPtr2 = bytes;
866 byte* intPtr3 = bytes;
869 byte* intPtr4 = bytes;
871 *intPtr4 = (byte)((
int)c >> 8);
878 if (encoderFallbackBuffer ==
null)
880 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
881 encoderFallbackBuffer.InternalInitialize(ptr4, ptr2, encoder, setEncoder:
true);
883 encoderFallbackBuffer.InternalFallback(c, ref chars);
891 byte* intPtr5 = bytes;
893 *intPtr5 = (byte)((
int)c2 >> 8);
894 byte* intPtr6 = bytes;
900 byte* intPtr7 = bytes;
903 byte* intPtr8 = bytes;
905 *intPtr8 = (byte)((
int)c2 >> 8);
909 if (encoderFallbackBuffer !=
null && encoderFallbackBuffer.bFallingBack)
911 encoderFallbackBuffer.MovePrevious();
917 ThrowBytesOverflow(encoder, bytes == ptr3);
921 if (c <=
'\0' || (encoder !=
null && !encoder.MustFlush))
927 throw new ArgumentException(Environment.GetResourceString(
"Argument_RecursiveFallback", c),
"chars");
929 if (encoderFallbackBuffer ==
null)
931 encoderFallbackBuffer = ((encoder !=
null) ? encoder.FallbackBuffer : encoderFallback.CreateFallbackBuffer());
932 encoderFallbackBuffer.InternalInitialize(ptr4, ptr2, encoder, setEncoder:
true);
934 encoderFallbackBuffer.InternalFallback(c, ref chars);
940 encoder.charLeftOver = c;
941 encoder.m_charsUsed = (int)(chars - ptr4);
943 return (
int)(bytes - ptr3);
947 internal unsafe
override int GetCharCount(
byte* bytes,
int count, DecoderNLS baseDecoder)
949 Decoder decoder = (Decoder)baseDecoder;
950 byte* ptr = bytes + count;
951 byte* byteStart = bytes;
954 int num2 = count >> 1;
955 ulong* ptr2 = (ulong*)(ptr - 7);
956 DecoderFallbackBuffer decoderFallbackBuffer =
null;
959 num = decoder.lastByte;
960 c = decoder.lastChar;
965 if (num >= 0 && (count & 1) == 1)
972 if (!bigEndian && ((
long)bytes & 7) == 0L && num == -1 && c ==
'\0')
975 for (ptr3 = (ulong*)bytes; ptr3 < ptr2; ptr3++)
977 if ((-9223231297218904064L & (
long)(*ptr3)) != 0L)
979 ulong num3 = (ulong)((-576188069258921984L & (
long)(*ptr3)) ^ -2882066263381583872L);
980 if ((((
long)num3 & -281474976710656
L) == 0L || (num3 & 0xFFFF00000000) == 0
L || (num3 & 4294901760u) == 0L || (num3 & 0xFFFF) == 0
L) && ((-287953294993589248L & (
long)(*ptr3)) ^ -2593835887162763264L) != 0
L)
994 byte* intPtr = bytes;
1005 int num4 = num << 8;
1006 byte* intPtr2 = bytes;
1007 bytes = intPtr2 + 1;
1008 c2 = (char)(num4 | *intPtr2);
1012 byte* intPtr3 = bytes;
1013 bytes = intPtr3 + 1;
1014 c2 = (char)((*intPtr3 << 8) | num);
1017 if (c2 >=
'\ud800' && c2 <=
'\udfff')
1024 byte[] array =
null;
1025 array = ((!bigEndian) ?
new byte[2]
1031 (byte)((
int)c >> 8),
1034 if (decoderFallbackBuffer ==
null)
1036 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1037 decoderFallbackBuffer.InternalInitialize(byteStart,
null);
1039 num2 += decoderFallbackBuffer.InternalFallback(array, bytes);
1046 byte[] array2 =
null;
1047 array2 = ((!bigEndian) ?
new byte[2]
1050 (
byte)((int)c2 >> 8)
1053 (byte)((
int)c2 >> 8),
1056 if (decoderFallbackBuffer ==
null)
1058 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1059 decoderFallbackBuffer.InternalInitialize(byteStart,
null);
1061 num2 += decoderFallbackBuffer.InternalFallback(array2, bytes);
1071 byte[] array3 =
null;
1072 array3 = ((!bigEndian) ?
new byte[2]
1078 (byte)((
int)c >> 8),
1081 if (decoderFallbackBuffer ==
null)
1083 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1084 decoderFallbackBuffer.InternalInitialize(byteStart,
null);
1086 num2 += decoderFallbackBuffer.InternalFallback(array3, bytes);
1090 if (decoder ==
null || decoder.MustFlush)
1095 byte[] array4 =
null;
1096 array4 = ((!bigEndian) ?
new byte[2]
1102 (byte)((
int)c >> 8),
1105 if (decoderFallbackBuffer ==
null)
1107 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1108 decoderFallbackBuffer.InternalInitialize(byteStart,
null);
1110 num2 += decoderFallbackBuffer.InternalFallback(array4, bytes);
1115 if (decoderFallbackBuffer ==
null)
1117 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1118 decoderFallbackBuffer.InternalInitialize(byteStart,
null);
1120 num2 += decoderFallbackBuffer.InternalFallback(
new byte[1]
1135 internal unsafe
override int GetChars(
byte* bytes,
int byteCount,
char* chars,
int charCount, DecoderNLS baseDecoder)
1137 Decoder decoder = (Decoder)baseDecoder;
1140 if (decoder !=
null)
1142 num = decoder.lastByte;
1143 c = decoder.lastChar;
1145 DecoderFallbackBuffer decoderFallbackBuffer =
null;
1146 byte* ptr = bytes + byteCount;
1147 char* ptr2 = chars + charCount;
1152 if (!bigEndian && ((
long)chars & 7) == 0
L && ((long)bytes & 7) == 0
L && num == -1 && c ==
'\0')
1154 ulong* ptr5 = (ulong*)(bytes - 7 + ((ptr - bytes >> 1 < ptr2 - chars) ? (ptr - bytes) : (ptr2 - chars << 1)));
1155 ulong* ptr6 = (ulong*)bytes;
1156 ulong* ptr7 = (ulong*)chars;
1159 if ((-9223231297218904064L & (
long)(*ptr6)) != 0L)
1161 ulong num2 = (ulong)((-576188069258921984L & (
long)(*ptr6)) ^ -2882066263381583872L);
1162 if ((((
long)num2 & -281474976710656
L) == 0L || (num2 & 0xFFFF00000000) == 0
L || (num2 & 4294901760u) == 0L || (num2 & 0xFFFF) == 0
L) && ((-287953294993589248L & (
long)(*ptr6)) ^ -2593835887162763264L) != 0
L)
1171 chars = (
char*)ptr7;
1172 bytes = (
byte*)ptr6;
1180 byte* intPtr = bytes;
1188 int num3 = num << 8;
1189 byte* intPtr2 = bytes;
1190 bytes = intPtr2 + 1;
1191 c2 = (char)(num3 | *intPtr2);
1195 byte* intPtr3 = bytes;
1196 bytes = intPtr3 + 1;
1197 c2 = (char)((*intPtr3 << 8) | num);
1200 if (c2 >=
'\ud800' && c2 <=
'\udfff')
1206 byte[] array =
null;
1207 array = ((!bigEndian) ?
new byte[2]
1213 (byte)((
int)c >> 8),
1216 if (decoderFallbackBuffer ==
null)
1218 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1219 decoderFallbackBuffer.InternalInitialize(ptr3, ptr2);
1221 if (!decoderFallbackBuffer.InternalFallback(array, bytes, ref chars))
1224 decoderFallbackBuffer.InternalReset();
1225 ThrowCharsOverflow(decoder, chars == ptr4);
1234 byte[] array2 =
null;
1235 array2 = ((!bigEndian) ?
new byte[2]
1238 (
byte)((int)c2 >> 8)
1241 (byte)((
int)c2 >> 8),
1244 if (decoderFallbackBuffer ==
null)
1246 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1247 decoderFallbackBuffer.InternalInitialize(ptr3, ptr2);
1249 if (!decoderFallbackBuffer.InternalFallback(array2, bytes, ref chars))
1252 decoderFallbackBuffer.InternalReset();
1253 ThrowCharsOverflow(decoder, chars == ptr4);
1258 if (chars >= ptr2 - 1)
1261 ThrowCharsOverflow(decoder, chars == ptr4);
1264 char* intPtr4 = chars;
1265 chars = intPtr4 + 1;
1271 byte[] array3 =
null;
1272 array3 = ((!bigEndian) ?
new byte[2]
1278 (byte)((
int)c >> 8),
1281 if (decoderFallbackBuffer ==
null)
1283 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1284 decoderFallbackBuffer.InternalInitialize(ptr3, ptr2);
1286 if (!decoderFallbackBuffer.InternalFallback(array3, bytes, ref chars))
1289 decoderFallbackBuffer.InternalReset();
1290 ThrowCharsOverflow(decoder, chars == ptr4);
1298 ThrowCharsOverflow(decoder, chars == ptr4);
1301 char* intPtr5 = chars;
1302 chars = intPtr5 + 1;
1305 if (decoder ==
null || decoder.MustFlush)
1309 byte[] array4 =
null;
1310 array4 = ((!bigEndian) ?
new byte[2]
1316 (byte)((
int)c >> 8),
1319 if (decoderFallbackBuffer ==
null)
1321 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1322 decoderFallbackBuffer.InternalInitialize(ptr3, ptr2);
1324 if (!decoderFallbackBuffer.InternalFallback(array4, bytes, ref chars))
1331 decoderFallbackBuffer.InternalReset();
1332 ThrowCharsOverflow(decoder, chars == ptr4);
1344 if (decoderFallbackBuffer ==
null)
1346 decoderFallbackBuffer = ((decoder !=
null) ? decoder.FallbackBuffer : decoderFallback.CreateFallbackBuffer());
1347 decoderFallbackBuffer.InternalInitialize(ptr3, ptr2);
1349 if (!decoderFallbackBuffer.InternalFallback(
new byte[1]
1352 }, bytes, ref chars))
1355 decoderFallbackBuffer.InternalReset();
1356 ThrowCharsOverflow(decoder, chars == ptr4);
1367 if (decoder !=
null)
1369 decoder.m_bytesUsed = (int)(bytes - ptr3);
1370 decoder.lastChar = c;
1371 decoder.lastByte = num;
1373 return (
int)(chars - ptr4);
1379 [__DynamicallyInvokable]
1382 return new EncoderNLS(
this);
1387 [__DynamicallyInvokable]
1390 return new Decoder(
this);
1395 [__DynamicallyInvokable]
1414 return EmptyArray<byte>.Value;
1424 [__DynamicallyInvokable]
1431 long num = (long)charCount + 1
L;
1432 if (base.EncoderFallback.MaxCharCount > 1)
1434 num *= base.EncoderFallback.MaxCharCount;
1437 if (num >
int.MaxValue)
1451 [__DynamicallyInvokable]
1458 long num = (long)(byteCount >> 1) + (long)(byteCount & 1) + 1;
1459 if (base.DecoderFallback.MaxCharCount > 1)
1461 num *= base.DecoderFallback.MaxCharCount;
1463 if (num >
int.MaxValue)
1474 [__DynamicallyInvokable]
1478 if (unicodeEncoding !=
null)
1480 if (
CodePage == unicodeEncoding.
CodePage && byteOrderMark == unicodeEncoding.byteOrderMark && bigEndian == unicodeEncoding.bigEndian && base.EncoderFallback.Equals(unicodeEncoding.
EncoderFallback))
1491 [__DynamicallyInvokable]
1494 return CodePage + base.EncoderFallback.GetHashCode() + base.DecoderFallback.GetHashCode() + (byteOrderMark ? 4 : 0) + (bigEndian ? 8 : 0);
Represents a character encoding.To browse the .NET Framework source code for this type,...
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
Encodes a set of characters from the specified T:System.String into the specified byte array.
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
override int GetMaxCharCount(int byteCount)
Calculates the maximum number of characters produced by decoding the specified number of bytes.
Converts a set of characters into a sequence of bytes.
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
Encodes a set of characters from the specified character array into the specified byte array.
override byte [] GetPreamble()
Returns a Unicode byte order mark encoded in UTF-16 format, if the constructor for this instance requ...
The exception that is thrown when the value of an argument is outside the allowable range of values a...
DecoderFallback DecoderFallback
Gets or sets the T:System.Text.DecoderFallback object for the current T:System.Text....
static DecoderFallback ExceptionFallback
Gets an object that throws an exception when an input byte sequence cannot be decoded.
EncoderFallback EncoderFallback
Gets or sets the T:System.Text.EncoderFallback object for the current T:System.Text....
Describes the source and destination of a given serialized stream, and provides an additional caller-...
override System.Text.Decoder GetDecoder()
Obtains a decoder that converts a UTF-16 encoded sequence of bytes into a sequence of Unicode charact...
override bool Equals(object value)
Determines whether the specified T:System.Object is equal to the current T:System....
Provides information about, and means to manipulate, the current environment and platform....
UnicodeEncoding(bool bigEndian, bool byteOrderMark)
Initializes a new instance of the T:System.Text.UnicodeEncoding class. Parameters specify whether to ...
Represents a UTF-16 encoding of Unicode characters.
override int GetHashCode()
Returns the hash code for the current instance.
virtual int CodePage
When overridden in a derived class, gets the code page identifier of the current T:System....
Converts a sequence of encoded bytes into a set of characters.
virtual string EncodingName
When overridden in a derived class, gets the human-readable description of the current encoding.
unsafe override int GetByteCount(char[] chars, int index, int count)
Calculates the number of bytes produced by encoding a set of characters from the specified character ...
Provides a failure-handling mechanism, called a fallback, for an encoded input byte sequence that can...
The exception thrown when an error occurs during serialization or deserialization.
UnicodeEncoding()
Initializes a new instance of the T:System.Text.UnicodeEncoding class.
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
Encodes a set of characters starting at the specified character pointer into a sequence of bytes that...
const int CharSize
Represents the Unicode character size in bytes. This field is a constant.
unsafe override int GetCharCount(byte[] bytes, int index, int count)
Calculates the number of characters produced by decoding a sequence of bytes from the specified byte ...
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
Decodes a sequence of bytes from the specified byte array into the specified character array.
Stores all the data needed to serialize or deserialize an object. This class cannot be inherited.
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
Decodes a sequence of bytes starting at the specified byte pointer into a set of characters that are ...
Allows an object to control its own serialization and deserialization.
unsafe override int GetByteCount(string s)
Calculates the number of bytes produced by encoding the characters in the specified string.
Specifies that the class can be serialized.
override Encoder GetEncoder()
Obtains an encoder that converts a sequence of Unicode characters into a UTF-16 encoded sequence of b...
unsafe override int GetCharCount(byte *bytes, int count)
Calculates the number of characters produced by decoding a sequence of bytes starting at the specifie...
Encoding()
Initializes a new instance of the T:System.Text.Encoding class.
static EncoderFallback ExceptionFallback
Gets an object that throws an exception when an input character cannot be encoded.
void GetObjectData(SerializationInfo info, StreamingContext context)
Populates a T:System.Runtime.Serialization.SerializationInfo with the data needed to serialize the ta...
unsafe override string GetString(byte[] bytes, int index, int count)
Decodes a range of bytes from a byte array into a string.
override int GetMaxByteCount(int charCount)
Calculates the maximum number of bytes produced by encoding the specified number of characters.
unsafe override int GetByteCount(char *chars, int count)
Calculates the number of bytes produced by encoding a set of characters starting at the specified cha...