Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
UTF32Encoding.cs
Go to the documentation of this file.
3
4namespace System.Text;
5
6public sealed class UTF32Encoding : Encoding
7{
8 private sealed class UTF32Decoder : DecoderNLS
9 {
10 internal int iChar;
11
12 internal int readByteCount;
13
14 internal override bool HasState => readByteCount != 0;
15
16 public UTF32Decoder(UTF32Encoding encoding)
17 : base(encoding)
18 {
19 }
20
21 public override void Reset()
22 {
23 iChar = 0;
24 readByteCount = 0;
25 if (_fallbackBuffer != null)
26 {
28 }
29 }
30 }
31
32 internal static readonly UTF32Encoding s_default = new UTF32Encoding(bigEndian: false, byteOrderMark: true);
33
34 internal static readonly UTF32Encoding s_bigEndianDefault = new UTF32Encoding(bigEndian: true, byteOrderMark: true);
35
36 private readonly bool _emitUTF32ByteOrderMark;
37
38 private readonly bool _isThrowException;
39
40 private readonly bool _bigEndian;
41
43 {
44 get
45 {
46 if (!(GetType() != typeof(UTF32Encoding)))
47 {
49 {
50 if (_bigEndian)
51 {
52 return new byte[4] { 0, 0, 254, 255 };
53 }
54 return new byte[4] { 255, 254, 0, 0 };
55 }
56 return default(ReadOnlySpan<byte>);
57 }
58 return new ReadOnlySpan<byte>(GetPreamble());
59 }
60 }
61
63 : this(bigEndian: false, byteOrderMark: true)
64 {
65 }
66
67 public UTF32Encoding(bool bigEndian, bool byteOrderMark)
68 : base(bigEndian ? 12001 : 12000)
69 {
70 _bigEndian = bigEndian;
71 _emitUTF32ByteOrderMark = byteOrderMark;
72 }
73
74 public UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters)
75 : this(bigEndian, byteOrderMark)
76 {
77 _isThrowException = throwOnInvalidCharacters;
79 {
81 }
82 }
83
97
98 public unsafe override int GetByteCount(char[] chars, int index, int count)
99 {
100 if (chars == null)
101 {
102 throw new ArgumentNullException("chars", SR.ArgumentNull_Array);
103 }
104 if (index < 0 || count < 0)
105 {
106 throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum);
107 }
108 if (chars.Length - index < count)
109 {
111 }
112 if (count == 0)
113 {
114 return 0;
115 }
116 fixed (char* ptr = chars)
117 {
118 return GetByteCount(ptr + index, count, null);
119 }
120 }
121
122 public unsafe override int GetByteCount(string s)
123 {
124 if (s == null)
125 {
127 }
128 fixed (char* pChars = s)
129 {
130 return GetByteCount(pChars, s.Length, null);
131 }
132 }
133
134 [CLSCompliant(false)]
135 public unsafe override int GetByteCount(char* chars, int count)
136 {
137 if (chars == null)
138 {
139 throw new ArgumentNullException("chars", SR.ArgumentNull_Array);
140 }
141 if (count < 0)
142 {
144 }
145 return GetByteCount(chars, count, null);
146 }
147
148 public unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
149 {
150 if (s == null || bytes == null)
151 {
152 throw new ArgumentNullException((s == null) ? "s" : "bytes", SR.ArgumentNull_Array);
153 }
154 if (charIndex < 0 || charCount < 0)
155 {
156 throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", SR.ArgumentOutOfRange_NeedNonNegNum);
157 }
158 if (s.Length - charIndex < charCount)
159 {
161 }
162 if (byteIndex < 0 || byteIndex > bytes.Length)
163 {
165 }
166 int byteCount = bytes.Length - byteIndex;
167 fixed (char* ptr = s)
168 {
169 fixed (byte* ptr2 = &MemoryMarshal.GetReference<byte>(bytes))
170 {
171 return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, null);
172 }
173 }
174 }
175
176 public unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
177 {
178 if (chars == null || bytes == null)
179 {
180 throw new ArgumentNullException((chars == null) ? "chars" : "bytes", SR.ArgumentNull_Array);
181 }
182 if (charIndex < 0 || charCount < 0)
183 {
184 throw new ArgumentOutOfRangeException((charIndex < 0) ? "charIndex" : "charCount", SR.ArgumentOutOfRange_NeedNonNegNum);
185 }
186 if (chars.Length - charIndex < charCount)
187 {
189 }
190 if (byteIndex < 0 || byteIndex > bytes.Length)
191 {
193 }
194 if (charCount == 0)
195 {
196 return 0;
197 }
198 int byteCount = bytes.Length - byteIndex;
199 fixed (char* ptr = chars)
200 {
201 fixed (byte* ptr2 = &MemoryMarshal.GetReference<byte>(bytes))
202 {
203 return GetBytes(ptr + charIndex, charCount, ptr2 + byteIndex, byteCount, null);
204 }
205 }
206 }
207
208 [CLSCompliant(false)]
209 public unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount)
210 {
211 if (bytes == null || chars == null)
212 {
213 throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", SR.ArgumentNull_Array);
214 }
215 if (charCount < 0 || byteCount < 0)
216 {
217 throw new ArgumentOutOfRangeException((charCount < 0) ? "charCount" : "byteCount", SR.ArgumentOutOfRange_NeedNonNegNum);
218 }
219 return GetBytes(chars, charCount, bytes, byteCount, null);
220 }
221
222 public unsafe override int GetCharCount(byte[] bytes, int index, int count)
223 {
224 if (bytes == null)
225 {
226 throw new ArgumentNullException("bytes", SR.ArgumentNull_Array);
227 }
228 if (index < 0 || count < 0)
229 {
230 throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum);
231 }
232 if (bytes.Length - index < count)
233 {
235 }
236 if (count == 0)
237 {
238 return 0;
239 }
240 fixed (byte* ptr = bytes)
241 {
242 return GetCharCount(ptr + index, count, null);
243 }
244 }
245
246 [CLSCompliant(false)]
247 public unsafe override int GetCharCount(byte* bytes, int count)
248 {
249 if (bytes == null)
250 {
251 throw new ArgumentNullException("bytes", SR.ArgumentNull_Array);
252 }
253 if (count < 0)
254 {
256 }
257 return GetCharCount(bytes, count, null);
258 }
259
260 public unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
261 {
262 if (bytes == null || chars == null)
263 {
264 throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", SR.ArgumentNull_Array);
265 }
266 if (byteIndex < 0 || byteCount < 0)
267 {
268 throw new ArgumentOutOfRangeException((byteIndex < 0) ? "byteIndex" : "byteCount", SR.ArgumentOutOfRange_NeedNonNegNum);
269 }
270 if (bytes.Length - byteIndex < byteCount)
271 {
273 }
274 if (charIndex < 0 || charIndex > chars.Length)
275 {
277 }
278 if (byteCount == 0)
279 {
280 return 0;
281 }
282 int charCount = chars.Length - charIndex;
283 fixed (byte* ptr = bytes)
284 {
285 fixed (char* ptr2 = &MemoryMarshal.GetReference<char>(chars))
286 {
287 return GetChars(ptr + byteIndex, byteCount, ptr2 + charIndex, charCount, null);
288 }
289 }
290 }
291
292 [CLSCompliant(false)]
293 public unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount)
294 {
295 if (bytes == null || chars == null)
296 {
297 throw new ArgumentNullException((bytes == null) ? "bytes" : "chars", SR.ArgumentNull_Array);
298 }
299 if (charCount < 0 || byteCount < 0)
300 {
301 throw new ArgumentOutOfRangeException((charCount < 0) ? "charCount" : "byteCount", SR.ArgumentOutOfRange_NeedNonNegNum);
302 }
303 return GetChars(bytes, byteCount, chars, charCount, null);
304 }
305
306 public unsafe override string GetString(byte[] bytes, int index, int count)
307 {
308 if (bytes == null)
309 {
310 throw new ArgumentNullException("bytes", SR.ArgumentNull_Array);
311 }
312 if (index < 0 || count < 0)
313 {
314 throw new ArgumentOutOfRangeException((index < 0) ? "index" : "count", SR.ArgumentOutOfRange_NeedNonNegNum);
315 }
316 if (bytes.Length - index < count)
317 {
319 }
320 if (count == 0)
321 {
322 return string.Empty;
323 }
324 fixed (byte* ptr = bytes)
325 {
326 return string.CreateStringFromEncoding(ptr + index, count, this);
327 }
328 }
329
330 internal unsafe override int GetByteCount(char* chars, int count, EncoderNLS encoder)
331 {
332 char* ptr = chars + count;
333 char* charStart = chars;
334 int num = 0;
335 char c = '\0';
336 EncoderFallbackBuffer encoderFallbackBuffer = null;
337 if (encoder != null)
338 {
339 c = encoder._charLeftOver;
340 encoderFallbackBuffer = encoder.FallbackBuffer;
341 if (encoderFallbackBuffer.Remaining > 0)
342 {
343 throw new ArgumentException(SR.Format(SR.Argument_EncoderFallbackNotEmpty, EncodingName, encoder.Fallback?.GetType().ToString() ?? string.Empty));
344 }
345 }
346 else
347 {
348 encoderFallbackBuffer = encoderFallback.CreateFallbackBuffer();
349 }
350 encoderFallbackBuffer.InternalInitialize(charStart, ptr, encoder, setEncoder: false);
351 while (true)
352 {
353 char c2;
354 if ((c2 = encoderFallbackBuffer.InternalGetNextChar()) != 0 || chars < ptr)
355 {
356 if (c2 == '\0')
357 {
358 c2 = *chars;
359 chars++;
360 }
361 if (c != 0)
362 {
363 if (char.IsLowSurrogate(c2))
364 {
365 c = '\0';
366 num += 4;
367 continue;
368 }
369 chars--;
370 char* chars2 = chars;
371 encoderFallbackBuffer.InternalFallback(c, ref chars2);
372 chars = chars2;
373 c = '\0';
374 }
375 else if (char.IsHighSurrogate(c2))
376 {
377 c = c2;
378 }
379 else if (char.IsLowSurrogate(c2))
380 {
381 char* chars2 = chars;
382 encoderFallbackBuffer.InternalFallback(c2, ref chars2);
383 chars = chars2;
384 }
385 else
386 {
387 num += 4;
388 }
389 }
390 else
391 {
392 if ((encoder != null && !encoder.MustFlush) || c <= '\0')
393 {
394 break;
395 }
396 char* chars2 = chars;
397 encoderFallbackBuffer.InternalFallback(c, ref chars2);
398 chars = chars2;
399 c = '\0';
400 }
401 }
402 if (num < 0)
403 {
405 }
406 return num;
407 }
408
409 internal unsafe override int GetBytes(char* chars, int charCount, byte* bytes, int byteCount, EncoderNLS encoder)
410 {
411 char* ptr = chars;
412 char* ptr2 = chars + charCount;
413 byte* ptr3 = bytes;
414 byte* ptr4 = bytes + byteCount;
415 char c = '\0';
416 EncoderFallbackBuffer encoderFallbackBuffer = null;
417 if (encoder != null)
418 {
419 c = encoder._charLeftOver;
420 encoderFallbackBuffer = encoder.FallbackBuffer;
421 if (encoder._throwOnOverflow && encoderFallbackBuffer.Remaining > 0)
422 {
424 }
425 }
426 else
427 {
428 encoderFallbackBuffer = encoderFallback.CreateFallbackBuffer();
429 }
430 encoderFallbackBuffer.InternalInitialize(ptr, ptr2, encoder, setEncoder: true);
431 while (true)
432 {
433 char c2;
434 char* chars2;
435 if ((c2 = encoderFallbackBuffer.InternalGetNextChar()) != 0 || chars < ptr2)
436 {
437 if (c2 == '\0')
438 {
439 c2 = *chars;
440 chars++;
441 }
442 if (c != 0)
443 {
444 if (!char.IsLowSurrogate(c2))
445 {
446 chars--;
447 chars2 = chars;
448 encoderFallbackBuffer.InternalFallback(c, ref chars2);
449 chars = chars2;
450 c = '\0';
451 continue;
452 }
453 uint surrogate = GetSurrogate(c, c2);
454 c = '\0';
455 if (bytes + 3 < ptr4)
456 {
457 if (_bigEndian)
458 {
459 *(bytes++) = 0;
460 *(bytes++) = (byte)(surrogate >> 16);
461 *(bytes++) = (byte)(surrogate >> 8);
462 *(bytes++) = (byte)surrogate;
463 }
464 else
465 {
466 *(bytes++) = (byte)surrogate;
467 *(bytes++) = (byte)(surrogate >> 8);
468 *(bytes++) = (byte)(surrogate >> 16);
469 *(bytes++) = 0;
470 }
471 continue;
472 }
473 if (encoderFallbackBuffer.bFallingBack)
474 {
475 encoderFallbackBuffer.MovePrevious();
476 encoderFallbackBuffer.MovePrevious();
477 }
478 else
479 {
480 chars -= 2;
481 }
482 ThrowBytesOverflow(encoder, bytes == ptr3);
483 c = '\0';
484 }
485 else
486 {
487 if (char.IsHighSurrogate(c2))
488 {
489 c = c2;
490 continue;
491 }
492 if (char.IsLowSurrogate(c2))
493 {
494 chars2 = chars;
495 encoderFallbackBuffer.InternalFallback(c2, ref chars2);
496 chars = chars2;
497 continue;
498 }
499 if (bytes + 3 < ptr4)
500 {
501 if (_bigEndian)
502 {
503 *(bytes++) = 0;
504 *(bytes++) = 0;
505 *(bytes++) = (byte)((uint)c2 >> 8);
506 *(bytes++) = (byte)c2;
507 }
508 else
509 {
510 *(bytes++) = (byte)c2;
511 *(bytes++) = (byte)((uint)c2 >> 8);
512 *(bytes++) = 0;
513 *(bytes++) = 0;
514 }
515 continue;
516 }
517 if (encoderFallbackBuffer.bFallingBack)
518 {
519 encoderFallbackBuffer.MovePrevious();
520 }
521 else
522 {
523 chars--;
524 }
525 ThrowBytesOverflow(encoder, bytes == ptr3);
526 }
527 }
528 if ((encoder != null && !encoder.MustFlush) || c <= '\0')
529 {
530 break;
531 }
532 chars2 = chars;
533 encoderFallbackBuffer.InternalFallback(c, ref chars2);
534 chars = chars2;
535 c = '\0';
536 }
537 if (encoder != null)
538 {
539 encoder._charLeftOver = c;
540 encoder._charsUsed = (int)(chars - ptr);
541 }
542 return (int)(bytes - ptr3);
543 }
544
545 internal unsafe override int GetCharCount(byte* bytes, int count, DecoderNLS baseDecoder)
546 {
547 UTF32Decoder uTF32Decoder = (UTF32Decoder)baseDecoder;
548 int num = 0;
549 byte* ptr = bytes + count;
550 byte* byteStart = bytes;
551 int num2 = 0;
552 uint num3 = 0u;
553 DecoderFallbackBuffer decoderFallbackBuffer = null;
554 if (uTF32Decoder != null)
555 {
556 num2 = uTF32Decoder.readByteCount;
557 num3 = (uint)uTF32Decoder.iChar;
558 decoderFallbackBuffer = uTF32Decoder.FallbackBuffer;
559 }
560 else
561 {
562 decoderFallbackBuffer = decoderFallback.CreateFallbackBuffer();
563 }
564 decoderFallbackBuffer.InternalInitialize(byteStart, null);
565 while (bytes < ptr && num >= 0)
566 {
567 if (_bigEndian)
568 {
569 num3 <<= 8;
570 num3 += *(bytes++);
571 }
572 else
573 {
574 num3 >>= 8;
575 num3 += (uint)(*(bytes++) << 24);
576 }
577 num2++;
578 if (num2 < 4)
579 {
580 continue;
581 }
582 num2 = 0;
583 if (num3 > 1114111 || (num3 >= 55296 && num3 <= 57343))
584 {
585 byte[] bytes2 = ((!_bigEndian) ? new byte[4]
586 {
587 (byte)num3,
588 (byte)(num3 >> 8),
589 (byte)(num3 >> 16),
590 (byte)(num3 >> 24)
591 } : new byte[4]
592 {
593 (byte)(num3 >> 24),
594 (byte)(num3 >> 16),
595 (byte)(num3 >> 8),
596 (byte)num3
597 });
598 num += decoderFallbackBuffer.InternalFallback(bytes2, bytes);
599 num3 = 0u;
600 }
601 else
602 {
603 if (num3 >= 65536)
604 {
605 num++;
606 }
607 num++;
608 num3 = 0u;
609 }
610 }
611 if (num2 > 0 && (uTF32Decoder == null || uTF32Decoder.MustFlush))
612 {
613 byte[] array = new byte[num2];
614 if (_bigEndian)
615 {
616 while (num2 > 0)
617 {
618 array[--num2] = (byte)num3;
619 num3 >>= 8;
620 }
621 }
622 else
623 {
624 while (num2 > 0)
625 {
626 array[--num2] = (byte)(num3 >> 24);
627 num3 <<= 8;
628 }
629 }
630 num += decoderFallbackBuffer.InternalFallback(array, bytes);
631 }
632 if (num < 0)
633 {
635 }
636 return num;
637 }
638
639 internal unsafe override int GetChars(byte* bytes, int byteCount, char* chars, int charCount, DecoderNLS baseDecoder)
640 {
641 UTF32Decoder uTF32Decoder = (UTF32Decoder)baseDecoder;
642 char* ptr = chars;
643 char* ptr2 = chars + charCount;
644 byte* ptr3 = bytes;
645 byte* ptr4 = bytes + byteCount;
646 int num = 0;
647 uint num2 = 0u;
648 DecoderFallbackBuffer decoderFallbackBuffer = null;
649 if (uTF32Decoder != null)
650 {
651 num = uTF32Decoder.readByteCount;
652 num2 = (uint)uTF32Decoder.iChar;
653 decoderFallbackBuffer = baseDecoder.FallbackBuffer;
654 }
655 else
656 {
657 decoderFallbackBuffer = decoderFallback.CreateFallbackBuffer();
658 }
659 decoderFallbackBuffer.InternalInitialize(bytes, chars + charCount);
660 while (bytes < ptr4)
661 {
662 if (_bigEndian)
663 {
664 num2 <<= 8;
665 num2 += *(bytes++);
666 }
667 else
668 {
669 num2 >>= 8;
670 num2 += (uint)(*(bytes++) << 24);
671 }
672 num++;
673 if (num < 4)
674 {
675 continue;
676 }
677 num = 0;
678 if (num2 > 1114111 || (num2 >= 55296 && num2 <= 57343))
679 {
680 byte[] bytes2 = ((!_bigEndian) ? new byte[4]
681 {
682 (byte)num2,
683 (byte)(num2 >> 8),
684 (byte)(num2 >> 16),
685 (byte)(num2 >> 24)
686 } : new byte[4]
687 {
688 (byte)(num2 >> 24),
689 (byte)(num2 >> 16),
690 (byte)(num2 >> 8),
691 (byte)num2
692 });
693 char* chars2 = chars;
694 bool flag = decoderFallbackBuffer.InternalFallback(bytes2, bytes, ref chars2);
695 chars = chars2;
696 if (!flag)
697 {
698 bytes -= 4;
699 num2 = 0u;
700 decoderFallbackBuffer.InternalReset();
701 ThrowCharsOverflow(uTF32Decoder, chars == ptr);
702 break;
703 }
704 num2 = 0u;
705 continue;
706 }
707 if (num2 >= 65536)
708 {
709 if (chars >= ptr2 - 1)
710 {
711 bytes -= 4;
712 num2 = 0u;
713 ThrowCharsOverflow(uTF32Decoder, chars == ptr);
714 break;
715 }
716 *(chars++) = GetHighSurrogate(num2);
717 num2 = GetLowSurrogate(num2);
718 }
719 else if (chars >= ptr2)
720 {
721 bytes -= 4;
722 num2 = 0u;
723 ThrowCharsOverflow(uTF32Decoder, chars == ptr);
724 break;
725 }
726 *(chars++) = (char)num2;
727 num2 = 0u;
728 }
729 if (num > 0 && (uTF32Decoder == null || uTF32Decoder.MustFlush))
730 {
731 byte[] array = new byte[num];
732 int num3 = num;
733 if (_bigEndian)
734 {
735 while (num3 > 0)
736 {
737 array[--num3] = (byte)num2;
738 num2 >>= 8;
739 }
740 }
741 else
742 {
743 while (num3 > 0)
744 {
745 array[--num3] = (byte)(num2 >> 24);
746 num2 <<= 8;
747 }
748 }
749 char* chars2 = chars;
750 bool flag2 = decoderFallbackBuffer.InternalFallback(array, bytes, ref chars2);
751 chars = chars2;
752 if (!flag2)
753 {
754 decoderFallbackBuffer.InternalReset();
755 ThrowCharsOverflow(uTF32Decoder, chars == ptr);
756 }
757 else
758 {
759 num = 0;
760 num2 = 0u;
761 }
762 }
763 if (uTF32Decoder != null)
764 {
765 uTF32Decoder.iChar = (int)num2;
766 uTF32Decoder.readByteCount = num;
767 uTF32Decoder._bytesUsed = (int)(bytes - ptr3);
768 }
769 return (int)(chars - ptr);
770 }
771
772 private static uint GetSurrogate(char cHigh, char cLow)
773 {
774 return (uint)((cHigh - 55296) * 1024 + (cLow - 56320) + 65536);
775 }
776
777 private static char GetHighSurrogate(uint iChar)
778 {
779 return (char)((iChar - 65536) / 1024 + 55296);
780 }
781
782 private static char GetLowSurrogate(uint iChar)
783 {
784 return (char)((iChar - 65536) % 1024 + 56320);
785 }
786
787 public override Decoder GetDecoder()
788 {
789 return new UTF32Decoder(this);
790 }
791
792 public override Encoder GetEncoder()
793 {
794 return new EncoderNLS(this);
795 }
796
797 public override int GetMaxByteCount(int charCount)
798 {
799 if (charCount < 0)
800 {
802 }
803 long num = (long)charCount + 1L;
804 if (base.EncoderFallback.MaxCharCount > 1)
805 {
806 num *= base.EncoderFallback.MaxCharCount;
807 }
808 num *= 4;
809 if (num > int.MaxValue)
810 {
812 }
813 return (int)num;
814 }
815
816 public override int GetMaxCharCount(int byteCount)
817 {
818 if (byteCount < 0)
819 {
821 }
822 int num = byteCount / 2 + 2;
823 if (base.DecoderFallback.MaxCharCount > 2)
824 {
825 num *= base.DecoderFallback.MaxCharCount;
826 num /= 2;
827 }
828 if (num > int.MaxValue)
829 {
831 }
832 return num;
833 }
834
835 public override byte[] GetPreamble()
836 {
838 {
839 if (!_bigEndian)
840 {
841 return new byte[4] { 255, 254, 0, 0 };
842 }
843 return new byte[4] { 0, 0, 254, 255 };
844 }
845 return Array.Empty<byte>();
846 }
847
848 public override bool Equals([NotNullWhen(true)] object? value)
849 {
850 if (value is UTF32Encoding uTF32Encoding)
851 {
852 if (_emitUTF32ByteOrderMark == uTF32Encoding._emitUTF32ByteOrderMark && _bigEndian == uTF32Encoding._bigEndian && base.EncoderFallback.Equals(uTF32Encoding.EncoderFallback))
853 {
854 return base.DecoderFallback.Equals(uTF32Encoding.DecoderFallback);
855 }
856 return false;
857 }
858 return false;
859 }
860
861 public override int GetHashCode()
862 {
863 return base.EncoderFallback.GetHashCode() + base.DecoderFallback.GetHashCode() + CodePage + (_emitUTF32ByteOrderMark ? 4 : 0) + (_bigEndian ? 8 : 0);
864 }
865}
static string ArgumentOutOfRange_Index
Definition SR.cs:30
static string Argument_EncoderFallbackNotEmpty
Definition SR.cs:590
static string ArgumentOutOfRange_IndexCount
Definition SR.cs:80
static string ArgumentOutOfRange_GetCharCountOverflow
Definition SR.cs:90
static string ArgumentOutOfRange_GetByteCountOverflow
Definition SR.cs:88
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ArgumentOutOfRange_IndexCountBuffer
Definition SR.cs:78
static string ArgumentNull_Array
Definition SR.cs:24
static string ArgumentOutOfRange_NeedNonNegNum
Definition SR.cs:32
Definition SR.cs:7
unsafe void InternalInitialize(byte *byteStart, char *charEnd)
virtual unsafe bool InternalFallback(byte[] bytes, byte *pBytes, ref char *chars)
static DecoderFallback ExceptionFallback
DecoderFallbackBuffer CreateFallbackBuffer()
new DecoderFallbackBuffer FallbackBuffer
Definition DecoderNLS.cs:24
DecoderFallbackBuffer _fallbackBuffer
Definition Decoder.cs:9
bool InternalFallback(ReadOnlySpan< char > chars, out int charsConsumed)
unsafe void InternalInitialize(char *charStart, char *charEnd, EncoderNLS encoder, bool setEncoder)
EncoderFallbackBuffer CreateFallbackBuffer()
static EncoderFallback ExceptionFallback
new EncoderFallback Fallback
Definition EncoderNLS.cs:21
new EncoderFallbackBuffer FallbackBuffer
Definition EncoderNLS.cs:26
EncoderFallback encoderFallback
Definition Encoding.cs:341
DecoderFallback decoderFallback
Definition Encoding.cs:343
virtual string EncodingName
Definition Encoding.cs:362
virtual int CodePage
Definition Encoding.cs:515
UTF32Decoder(UTF32Encoding encoding)
unsafe override int GetByteCount(string s)
override void SetDefaultFallbacks()
unsafe override int GetByteCount(char[] chars, int index, int count)
static readonly UTF32Encoding s_bigEndianDefault
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount)
override int GetMaxCharCount(int byteCount)
static char GetHighSurrogate(uint iChar)
readonly bool _emitUTF32ByteOrderMark
override Encoder GetEncoder()
override int GetMaxByteCount(int charCount)
unsafe override int GetCharCount(byte *bytes, int count, DecoderNLS baseDecoder)
unsafe override string GetString(byte[] bytes, int index, int count)
unsafe override int GetBytes(string s, int charIndex, int charCount, byte[] bytes, int byteIndex)
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount)
unsafe override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
override byte[] GetPreamble()
unsafe override int GetBytes(char *chars, int charCount, byte *bytes, int byteCount, EncoderNLS encoder)
unsafe override int GetByteCount(char *chars, int count, EncoderNLS encoder)
unsafe override int GetCharCount(byte[] bytes, int index, int count)
UTF32Encoding(bool bigEndian, bool byteOrderMark)
UTF32Encoding(bool bigEndian, bool byteOrderMark, bool throwOnInvalidCharacters)
unsafe override int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
readonly bool _isThrowException
unsafe override int GetByteCount(char *chars, int count)
override Decoder GetDecoder()
override bool Equals([NotNullWhen(true)] object? value)
unsafe override int GetCharCount(byte *bytes, int count)
override ReadOnlySpan< byte > Preamble
static uint GetSurrogate(char cHigh, char cLow)
unsafe override int GetChars(byte *bytes, int byteCount, char *chars, int charCount, DecoderNLS baseDecoder)
static char GetLowSurrogate(uint iChar)
static readonly UTF32Encoding s_default
static void ThrowArgumentNullException(string name)