Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
Utf8Utility.cs
Go to the documentation of this file.
9
10namespace System.Text.Unicode;
11
12internal static class Utf8Utility
13{
14 [MethodImpl(MethodImplOptions.AggressiveInlining)]
16 {
18 return ((value & 0x3F0000) >> 16) | ((value & 0x3F00) >> 2) | ((value & 0xF) << 12);
19 }
20
21 [MethodImpl(MethodImplOptions.AggressiveInlining)]
23 {
25 uint num = (uint)((byte)value << 6);
26 return (byte)(value >> 8) + num - 12288 - 128;
27 }
28
29 [MethodImpl(MethodImplOptions.AggressiveInlining)]
30 private static uint ExtractCharsFromFourByteSequence(uint value)
31 {
33 uint num = (uint)((byte)value << 8);
34 num |= (value & 0x3F00) >> 6;
35 num |= (value & 0x300000) >> 20;
36 num |= (value & 0x3F000000) >> 8;
37 num |= (value & 0xF0000) << 6;
38 num -= 64;
39 num -= 8192;
40 num += 2048;
41 return num + 3690987520u;
42 }
43
44 [MethodImpl(MethodImplOptions.AggressiveInlining)]
46 {
48 value += 64;
49 uint value2 = BinaryPrimitives.ReverseEndianness(value & 0x3F0700u);
50 value2 = BitOperations.RotateLeft(value2, 16);
51 uint num = (value & 0xFC) << 6;
52 uint num2 = (value >> 6) & 0xF0000u;
53 num2 |= num;
54 uint num3 = (value & 3) << 20;
55 num3 |= 0x808080F0u;
56 return num3 | value2 | num2;
57 }
58
59 [MethodImpl(MethodImplOptions.AggressiveInlining)]
61 {
63 return ((value & 0x3F003F00) >> 8) | ((value & 0x1F001F) << 6);
64 }
65
66 [MethodImpl(MethodImplOptions.AggressiveInlining)]
68 {
70 return ((value >> 6) & 0x1F001F) + ((value << 8) & 0x3F003F00) + 2160099520u;
71 }
72
73 [MethodImpl(MethodImplOptions.AggressiveInlining)]
75 {
77 uint num = (value << 2) & 0x1F00u;
78 value &= 0x3Fu;
79 return BinaryPrimitives.ReverseEndianness((ushort)(num + value + 49280));
80 }
81
82 [MethodImpl(MethodImplOptions.AggressiveInlining)]
83 private static bool IsFirstCharAscii(uint value)
84 {
86 if ((value & 0xFF80u) != 0)
87 {
89 {
90 }
91 return false;
92 }
93 return true;
94 }
95
96 [MethodImpl(MethodImplOptions.AggressiveInlining)]
97 private static bool IsFirstCharAtLeastThreeUtf8Bytes(uint value)
98 {
100 if ((value & 0xF800) == 0)
101 {
103 {
104 }
105 return false;
106 }
107 return true;
108 }
109
110 [MethodImpl(MethodImplOptions.AggressiveInlining)]
111 private static bool IsFirstCharSurrogate(uint value)
112 {
114 if (((value - 55296) & 0xF800u) != 0)
115 {
117 {
118 }
119 return false;
120 }
121 return true;
122 }
123
124 [MethodImpl(MethodImplOptions.AggressiveInlining)]
125 private static bool IsFirstCharTwoUtf8Bytes(uint value)
126 {
128 if (((value - 128) & 0xFFFF) >= 1920)
129 {
131 {
132 }
133 return false;
134 }
135 return true;
136 }
137
138 [MethodImpl(MethodImplOptions.AggressiveInlining)]
139 private static bool IsLowByteUtf8ContinuationByte(uint value)
140 {
141 return (uint)(byte)(value - 128) <= 63u;
142 }
143
144 [MethodImpl(MethodImplOptions.AggressiveInlining)]
145 private static bool IsSecondCharAscii(uint value)
146 {
148 if (value >= 8388608)
149 {
151 {
152 }
153 return false;
154 }
155 return true;
156 }
157
158 [MethodImpl(MethodImplOptions.AggressiveInlining)]
159 private static bool IsSecondCharAtLeastThreeUtf8Bytes(uint value)
160 {
162 if ((value & 0xF8000000u) == 0)
163 {
165 {
166 }
167 return false;
168 }
169 return true;
170 }
171
172 [MethodImpl(MethodImplOptions.AggressiveInlining)]
173 private static bool IsSecondCharSurrogate(uint value)
174 {
176 if ((uint)((int)value - -671088640) >= 134217728u)
177 {
179 {
180 }
181 return false;
182 }
183 return true;
184 }
185
186 [MethodImpl(MethodImplOptions.AggressiveInlining)]
187 private static bool IsSecondCharTwoUtf8Bytes(uint value)
188 {
190 if (!UnicodeUtility.IsInRangeInclusive(value, 8388608u, 134217727u))
191 {
193 {
194 }
195 return false;
196 }
197 return true;
198 }
199
200 [MethodImpl(MethodImplOptions.AggressiveInlining)]
201 internal static bool IsUtf8ContinuationByte(in byte value)
202 {
203 return (sbyte)value < -64;
204 }
205
206 [MethodImpl(MethodImplOptions.AggressiveInlining)]
207 private static bool IsWellFormedUtf16SurrogatePair(uint value)
208 {
210 if (((value - 3691042816u) & 0xFC00FC00u) != 0)
211 {
213 {
214 }
215 return false;
216 }
217 return true;
218 }
219
220 [MethodImpl(MethodImplOptions.AggressiveInlining)]
221 private static uint ToLittleEndian(uint value)
222 {
224 return value;
225 }
226
227 [MethodImpl(MethodImplOptions.AggressiveInlining)]
229 {
231 if ((uint)(byte)value >= 194u)
232 {
234 {
235 }
236 return false;
237 }
238 return true;
239 }
240
241 [MethodImpl(MethodImplOptions.AggressiveInlining)]
242 private static bool UInt32BeginsWithUtf8FourByteMask(uint value)
243 {
245 if (((value - 2155905264u) & 0xC0C0C0F8u) != 0)
246 {
248 {
249 }
250 return false;
251 }
252 return true;
253 }
254
255 [MethodImpl(MethodImplOptions.AggressiveInlining)]
256 private static bool UInt32BeginsWithUtf8ThreeByteMask(uint value)
257 {
259 if (((value - 8421600) & 0xC0C0F0u) != 0)
260 {
262 {
263 }
264 return false;
265 }
266 return true;
267 }
268
269 [MethodImpl(MethodImplOptions.AggressiveInlining)]
270 private static bool UInt32BeginsWithUtf8TwoByteMask(uint value)
271 {
273 if (((value - 32960) & 0xC0E0u) != 0)
274 {
276 {
277 }
278 return false;
279 }
280 return true;
281 }
282
283 [MethodImpl(MethodImplOptions.AggressiveInlining)]
285 {
287 if (!UnicodeUtility.IsInRangeInclusive(value & 0xC0FFu, 32962u, 32991u))
288 {
290 {
291 }
292 return false;
293 }
294 return true;
295 }
296
297 [MethodImpl(MethodImplOptions.AggressiveInlining)]
299 {
301 if (!UnicodeUtility.IsInRangeInclusive(value & 0xC0FF0000u, 2160197632u, 2162098176u))
302 {
304 {
305 }
306 return false;
307 }
308 return true;
309 }
310
311 [MethodImpl(MethodImplOptions.AggressiveInlining)]
312 private static bool UInt32FirstByteIsAscii(uint value)
313 {
315 if ((value & 0x80u) != 0)
316 {
318 {
319 }
320 return false;
321 }
322 return true;
323 }
324
325 [MethodImpl(MethodImplOptions.AggressiveInlining)]
326 private static bool UInt32FourthByteIsAscii(uint value)
327 {
329 if ((int)value < 0)
330 {
332 {
333 }
334 return false;
335 }
336 return true;
337 }
338
339 [MethodImpl(MethodImplOptions.AggressiveInlining)]
340 private static bool UInt32SecondByteIsAscii(uint value)
341 {
343 if ((value & 0x8000u) != 0)
344 {
346 {
347 }
348 return false;
349 }
350 return true;
351 }
352
353 [MethodImpl(MethodImplOptions.AggressiveInlining)]
354 private static bool UInt32ThirdByteIsAscii(uint value)
355 {
357 if ((value & 0x800000u) != 0)
358 {
360 {
361 }
362 return false;
363 }
364 return true;
365 }
366
367 [MethodImpl(MethodImplOptions.AggressiveInlining)]
368 private static void WriteTwoUtf16CharsAsTwoUtf8ThreeByteSequences(ref byte outputBuffer, uint value)
369 {
371 uint num = ((value << 2) & 0x3F00u) | ((value & 0x3F) << 16);
372 uint num2 = ((value >> 4) & 0xF000000u) | ((value >> 12) & 0xFu);
373 Unsafe.WriteUnaligned(ref outputBuffer, num + num2 + 3766517984u);
374 Unsafe.WriteUnaligned(ref Unsafe.Add(ref outputBuffer, 4), (ushort)(((value >> 22) & 0x3F) + ((value >> 8) & 0x3F00) + 32896));
375 }
376
377 [MethodImpl(MethodImplOptions.AggressiveInlining)]
378 private static void WriteFirstUtf16CharAsUtf8ThreeByteSequence(ref byte outputBuffer, uint value)
379 {
381 uint num = (value << 2) & 0x3F00u;
382 uint num2 = (uint)(ushort)value >> 12;
383 Unsafe.WriteUnaligned(ref outputBuffer, (ushort)(num + num2 + 32992));
384 Unsafe.Add(ref outputBuffer, 2) = (byte)((value & 0x3Fu) | 0xFFFFFF80u);
385 }
386
387 public unsafe static OperationStatus TranscodeToUtf16(byte* pInputBuffer, int inputLength, char* pOutputBuffer, int outputCharsRemaining, out byte* pInputBufferRemaining, out char* pOutputBufferRemaining)
388 {
389 nuint num = ASCIIUtility.WidenAsciiToUtf16(pInputBuffer, pOutputBuffer, (uint)Math.Min(inputLength, outputCharsRemaining));
390 pInputBuffer += num;
391 pOutputBuffer += num;
392 if ((int)num == inputLength)
393 {
394 pInputBufferRemaining = pInputBuffer;
395 pOutputBufferRemaining = pOutputBuffer;
396 return OperationStatus.Done;
397 }
398 inputLength -= (int)num;
399 outputCharsRemaining -= (int)num;
400 if (inputLength < 4)
401 {
402 goto IL_0690;
403 }
404 byte* ptr = pInputBuffer + (uint)inputLength - 4;
405 while (true)
406 {
407 IL_004a:
408 uint num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
409 while (true)
410 {
411 IL_0051:
413 {
414 goto IL_0120;
415 }
416 int num4;
417 uint num5;
418 if (outputCharsRemaining >= 4)
419 {
421 pInputBuffer += 4;
422 pOutputBuffer += 4;
423 outputCharsRemaining -= 4;
424 uint val = (uint)((int)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *ptr) + 4);
425 uint num3 = Math.Min(val, (uint)outputCharsRemaining) / 8;
426 num4 = 0;
427 while ((uint)num4 < num3)
428 {
429 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
430 num5 = Unsafe.ReadUnaligned<uint>(pInputBuffer + 4);
431 if (ASCIIUtility.AllBytesInUInt32AreAscii(num2 | num5))
432 {
433 pInputBuffer += 8;
436 pOutputBuffer += 8;
437 num4++;
438 continue;
439 }
440 goto IL_00f4;
441 }
442 outputCharsRemaining -= 8 * num4;
443 goto IL_04aa;
444 }
445 goto IL_04b1;
446 IL_04b1:
447 inputLength = (int)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *ptr) + 4;
448 goto IL_0690;
449 IL_04aa:
450 if (pInputBuffer <= ptr)
451 {
452 goto IL_004a;
453 }
454 goto IL_04b1;
455 IL_0120:
456 if (UInt32FirstByteIsAscii(num2))
457 {
458 if (outputCharsRemaining >= 3)
459 {
460 uint num6 = ToLittleEndian(num2);
461 nuint num7 = 1u;
462 *pOutputBuffer = (char)(byte)num6;
463 if (UInt32SecondByteIsAscii(num2))
464 {
465 num7++;
466 num6 >>= 8;
467 pOutputBuffer[1] = (char)(byte)num6;
468 if (UInt32ThirdByteIsAscii(num2))
469 {
470 num7++;
471 num6 >>= 8;
472 pOutputBuffer[2] = (char)(byte)num6;
473 }
474 }
475 pInputBuffer += num7;
476 pOutputBuffer += num7;
477 outputCharsRemaining -= (int)num7;
478 }
479 else
480 {
481 if (outputCharsRemaining == 0)
482 {
483 break;
484 }
485 uint num8 = ToLittleEndian(num2);
486 pInputBuffer++;
487 *(pOutputBuffer++) = (char)(byte)num8;
488 outputCharsRemaining--;
489 if (UInt32SecondByteIsAscii(num2))
490 {
491 if (outputCharsRemaining == 0)
492 {
493 break;
494 }
495 pInputBuffer++;
496 num8 >>= 8;
497 *(pOutputBuffer++) = (char)(byte)num8;
498 if (UInt32ThirdByteIsAscii(num2))
499 {
500 break;
501 }
502 outputCharsRemaining = 0;
503 }
504 }
505 if (pInputBuffer > ptr)
506 {
507 goto IL_04b1;
508 }
509 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
510 }
511 uint num9;
513 {
515 {
516 while (true)
517 {
520 {
521 break;
522 }
523 if (outputCharsRemaining >= 2)
524 {
525 Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoCharsPackedFromTwoAdjacentTwoByteSequences(num2));
526 pInputBuffer += 4;
527 pOutputBuffer += 2;
528 outputCharsRemaining -= 2;
529 if (pInputBuffer <= ptr)
530 {
531 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
534 {
535 goto IL_0051;
536 }
537 continue;
538 }
539 }
540 goto IL_04b1;
541 }
543 if (UInt32ThirdByteIsAscii(num2))
544 {
545 if (UInt32FourthByteIsAscii(num2))
546 {
547 goto IL_0282;
548 }
549 if (outputCharsRemaining >= 2)
550 {
551 *pOutputBuffer = (char)num9;
552 char* num10 = pOutputBuffer + 1;
553 uint num11 = num2;
555 {
556 }
557 *num10 = (char)(byte)(num11 >> 16);
558 pInputBuffer += 3;
559 pOutputBuffer += 2;
560 outputCharsRemaining -= 2;
561 if (ptr >= pInputBuffer)
562 {
563 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
564 continue;
565 }
566 }
567 }
568 else if (outputCharsRemaining != 0)
569 {
570 *pOutputBuffer = (char)num9;
571 pInputBuffer += 2;
572 pOutputBuffer++;
573 outputCharsRemaining--;
574 if (ptr >= pInputBuffer)
575 {
576 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
577 break;
578 }
579 }
580 goto IL_04b1;
581 }
582 goto IL_06a3;
583 }
585 {
586 while (true)
587 {
589 if ((num2 & 0x200F) == 0 || ((num2 - 8205) & 0x200F) == 0)
590 {
591 break;
592 }
593 if (outputCharsRemaining == 0)
594 {
595 goto end_IL_0051;
596 }
598 if ((((int)num2 - -536870912) & -268435456) == 0 && outputCharsRemaining > 1 && (nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *ptr) >= (nint)3)
599 {
600 uint num12 = Unsafe.ReadUnaligned<uint>(pInputBuffer + 3);
601 if (UInt32BeginsWithUtf8ThreeByteMask(num12) && (num12 & 0x200Fu) != 0 && ((num12 - 8205) & 0x200Fu) != 0)
602 {
603 *pOutputBuffer = (char)ExtractCharFromFirstThreeByteSequence(num2);
604 pOutputBuffer[1] = (char)ExtractCharFromFirstThreeByteSequence(num12);
605 pInputBuffer += 6;
606 pOutputBuffer += 2;
607 outputCharsRemaining -= 2;
608 goto IL_03ff;
609 }
610 }
611 *pOutputBuffer = (char)ExtractCharFromFirstThreeByteSequence(num2);
612 pInputBuffer += 3;
613 pOutputBuffer++;
614 outputCharsRemaining--;
615 goto IL_03ff;
616 IL_03ff:
617 if (UInt32FourthByteIsAscii(num2))
618 {
619 if (outputCharsRemaining == 0)
620 {
621 goto end_IL_0051;
622 }
624 *pOutputBuffer = (char)(num2 >> 24);
625 pInputBuffer++;
626 pOutputBuffer++;
627 outputCharsRemaining--;
628 }
629 if (pInputBuffer <= ptr)
630 {
631 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
633 {
634 goto IL_0051;
635 }
636 continue;
637 }
638 goto IL_04b1;
639 }
640 }
642 {
644 uint value = num2 & 0xFFFFu;
646 if (UnicodeUtility.IsInRangeInclusive(value, 4026531984u, 4093640847u))
647 {
648 if (outputCharsRemaining < 2)
649 {
650 break;
651 }
652 Unsafe.WriteUnaligned(pOutputBuffer, ExtractCharsFromFourByteSequence(num2));
653 pInputBuffer += 4;
654 pOutputBuffer += 2;
655 outputCharsRemaining -= 2;
656 goto IL_04aa;
657 }
658 }
659 goto IL_06a3;
660 IL_0282:
661 if (outputCharsRemaining >= 3)
662 {
663 *pOutputBuffer = (char)num9;
665 num2 >>= 16;
666 pOutputBuffer[1] = (char)(byte)num2;
667 num2 >>= 8;
668 pOutputBuffer[2] = (char)num2;
669 pInputBuffer += 4;
670 pOutputBuffer += 3;
671 outputCharsRemaining -= 3;
672 goto IL_04aa;
673 }
674 goto IL_04b1;
675 IL_00f4:
677 {
679 num2 = num5;
680 pInputBuffer += 4;
681 pOutputBuffer += 4;
682 outputCharsRemaining -= 4;
683 }
684 outputCharsRemaining -= 8 * num4;
685 goto IL_0120;
686 continue;
687 end_IL_0051:
688 break;
689 }
690 break;
691 }
692 goto IL_069f;
693 IL_06a3:
694 OperationStatus result = OperationStatus.InvalidData;
695 goto IL_06a5;
696 IL_069f:
697 result = OperationStatus.DestinationTooSmall;
698 goto IL_06a5;
699 IL_06a5:
700 pInputBufferRemaining = pInputBuffer;
701 pOutputBufferRemaining = pOutputBuffer;
702 return result;
703 IL_0690:
704 while (true)
705 {
706 if (inputLength > 0)
707 {
708 uint num13 = *pInputBuffer;
709 if (num13 <= 127)
710 {
711 if (outputCharsRemaining != 0)
712 {
713 *pOutputBuffer = (char)num13;
714 pInputBuffer++;
715 pOutputBuffer++;
716 inputLength--;
717 outputCharsRemaining--;
718 continue;
719 }
720 goto IL_069f;
721 }
722 num13 -= 194;
723 if ((uint)(byte)num13 <= 29u)
724 {
725 if (inputLength < 2)
726 {
727 goto IL_069b;
728 }
729 uint num14 = pInputBuffer[1];
731 {
732 if (outputCharsRemaining != 0)
733 {
734 uint num15 = (num13 << 6) + num14 + 128 - 128;
735 *pOutputBuffer = (char)num15;
736 pInputBuffer += 2;
737 pOutputBuffer++;
738 inputLength -= 2;
739 outputCharsRemaining--;
740 continue;
741 }
742 goto IL_069f;
743 }
744 }
745 else if ((uint)(byte)num13 <= 45u)
746 {
747 if (inputLength >= 3)
748 {
749 uint num16 = pInputBuffer[1];
750 uint num17 = pInputBuffer[2];
752 {
753 uint num18 = (num13 << 12) + (num16 << 6);
754 if (num18 >= 133120)
755 {
756 num18 -= 186368;
757 if (num18 >= 2048)
758 {
759 if (outputCharsRemaining != 0)
760 {
761 num18 += num17;
762 num18 += 55296;
763 num18 -= 128;
764 *pOutputBuffer = (char)num18;
765 pInputBuffer += 3;
766 pOutputBuffer++;
767 inputLength -= 3;
768 outputCharsRemaining--;
769 continue;
770 }
771 goto IL_069f;
772 }
773 }
774 }
775 }
776 else
777 {
778 if (inputLength < 2)
779 {
780 goto IL_069b;
781 }
782 uint num19 = pInputBuffer[1];
784 {
785 uint num20 = (num13 << 6) + num19;
786 if (num20 >= 2080 && !UnicodeUtility.IsInRangeInclusive(num20, 2912u, 2943u))
787 {
788 goto IL_069b;
789 }
790 }
791 }
792 }
793 else if ((uint)(byte)num13 <= 50u)
794 {
795 if (inputLength < 2)
796 {
797 goto IL_069b;
798 }
799 uint num21 = pInputBuffer[1];
801 {
802 uint value2 = (num13 << 6) + num21;
803 if (UnicodeUtility.IsInRangeInclusive(value2, 3088u, 3343u))
804 {
805 if (inputLength < 3)
806 {
807 goto IL_069b;
808 }
809 if (IsLowByteUtf8ContinuationByte(pInputBuffer[2]))
810 {
811 if (inputLength < 4)
812 {
813 goto IL_069b;
814 }
815 if (IsLowByteUtf8ContinuationByte(pInputBuffer[3]))
816 {
817 goto IL_069f;
818 }
819 }
820 }
821 }
822 }
823 goto IL_06a3;
824 }
825 result = OperationStatus.Done;
826 break;
827 IL_069b:
828 result = OperationStatus.NeedMoreData;
829 break;
830 }
831 goto IL_06a5;
832 }
833
834 public unsafe static OperationStatus TranscodeToUtf8(char* pInputBuffer, int inputLength, byte* pOutputBuffer, int outputBytesRemaining, out char* pInputBufferRemaining, out byte* pOutputBufferRemaining)
835 {
836 nuint num = ASCIIUtility.NarrowUtf16ToAscii(pInputBuffer, pOutputBuffer, (uint)Math.Min(inputLength, outputBytesRemaining));
837 pInputBuffer += num;
838 pOutputBuffer += num;
839 if ((int)num == inputLength)
840 {
841 pInputBufferRemaining = pInputBuffer;
842 pOutputBufferRemaining = pOutputBuffer;
843 return OperationStatus.Done;
844 }
845 inputLength -= (int)num;
846 outputBytesRemaining -= (int)num;
847 if (inputLength < 2)
848 {
849 goto IL_04f0;
850 }
851 char* ptr = pInputBuffer + (uint)inputLength - 2;
854 {
855 value = Vector128.Create((short)(-128));
856 }
857 uint num2;
858 while (true)
859 {
860 IL_006d:
861 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
862 while (true)
863 {
864 IL_0074:
866 {
867 goto IL_02e9;
868 }
869 if (outputBytesRemaining < 2)
870 {
871 break;
872 }
873 uint num3 = num2 | (num2 >> 8);
874 Unsafe.WriteUnaligned(pOutputBuffer, (ushort)num3);
875 pInputBuffer += 2;
876 pOutputBuffer += 2;
877 outputBytesRemaining -= 2;
878 uint num4 = (uint)((int)(ptr - pInputBuffer) + 2);
879 uint num5 = (uint)Math.Min(num4, outputBytesRemaining);
880 int num7;
881 ulong num8;
882 Vector128<short> vector;
883 int num10;
884 uint num11;
886 {
887 uint num6 = num5 / 8;
888 num7 = 0;
889 while ((uint)num7 < num6)
890 {
891 Unsafe.SkipInit<Vector128<short>>(out value);
892 vector = Unsafe.ReadUnaligned<Vector128<short>>(pInputBuffer);
894 {
895 }
896 if (Sse41.TestZ(vector, value))
897 {
898 Sse2.StoreScalar((ulong*)pOutputBuffer, Sse2.PackUnsignedSaturate(vector, vector).AsUInt64());
899 pInputBuffer += 8;
900 pOutputBuffer += 8;
901 num7++;
902 continue;
903 }
904 goto IL_019c;
905 }
906 outputBytesRemaining -= 8 * num7;
907 if ((num5 & 4u) != 0)
908 {
909 num8 = Unsafe.ReadUnaligned<ulong>(pInputBuffer);
911 {
912 goto IL_0213;
913 }
914 vector = Vector128.CreateScalarUnsafe(num8).AsInt16();
916 {
917 }
918 Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(vector, vector).AsUInt32()));
919 pInputBuffer += 4;
920 pOutputBuffer += 4;
921 outputBytesRemaining -= 4;
922 }
923 }
924 else
925 {
926 uint num9 = num5 / 4;
927 num10 = 0;
928 while ((uint)num10 < num9)
929 {
930 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
931 num11 = Unsafe.ReadUnaligned<uint>(pInputBuffer + 2);
932 if (Utf16Utility.AllCharsInUInt32AreAscii(num2 | num11))
933 {
934 Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(num2 | (num2 >> 8)));
935 Unsafe.WriteUnaligned(pOutputBuffer + 2, (ushort)(num11 | (num11 >> 8)));
936 pInputBuffer += 4;
937 pOutputBuffer += 4;
938 num10++;
939 continue;
940 }
941 goto IL_02b8;
942 }
943 outputBytesRemaining -= 4 * num10;
944 }
945 goto IL_04de;
946 IL_04ae:
948 {
949 if (outputBytesRemaining >= 4)
950 {
951 Unsafe.WriteUnaligned(pOutputBuffer, ExtractFourUtf8BytesFromSurrogatePair(num2));
952 pInputBuffer += 2;
953 pOutputBuffer += 4;
954 outputBytesRemaining -= 4;
955 goto IL_04de;
956 }
957 goto IL_05a7;
958 }
959 goto IL_05ac;
960 IL_038f:
961 if (outputBytesRemaining >= 3)
962 {
964 num2 >>= 16;
965 pOutputBuffer[2] = (byte)num2;
966 pInputBuffer += 2;
967 pOutputBuffer += 3;
968 outputBytesRemaining -= 3;
969 goto IL_04de;
970 }
971 pInputBuffer++;
972 pOutputBuffer += 2;
973 goto IL_05a7;
974 IL_04de:
975 if (pInputBuffer <= ptr)
976 {
977 goto IL_006d;
978 }
979 goto IL_04e5;
980 IL_04e5:
981 inputLength = (int)(ptr - pInputBuffer) + 2;
982 goto IL_04f0;
983 IL_0213:
984 num2 = (uint)num8;
986 {
987 Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(num2 | (num2 >> 8)));
988 pInputBuffer += 2;
989 pOutputBuffer += 2;
990 outputBytesRemaining -= 2;
991 num2 = (uint)(num8 >> 32);
992 }
993 goto IL_02e9;
994 IL_019c:
995 outputBytesRemaining -= 8 * num7;
996 num8 = ((!Sse2.X64.IsSupported) ? vector.AsUInt64().ToScalar() : Sse2.X64.ConvertToUInt64(vector.AsUInt64()));
998 {
1000 {
1001 }
1002 Unsafe.WriteUnaligned(pOutputBuffer, Sse2.ConvertToUInt32(Sse2.PackUnsignedSaturate(vector, vector).AsUInt32()));
1003 pInputBuffer += 4;
1004 pOutputBuffer += 4;
1005 outputBytesRemaining -= 4;
1006 num8 = vector.AsUInt64().GetElement(1);
1007 }
1008 goto IL_0213;
1009 IL_02b8:
1010 outputBytesRemaining -= 4 * num10;
1012 {
1013 Unsafe.WriteUnaligned(pOutputBuffer, (ushort)(num2 | (num2 >> 8)));
1014 pInputBuffer += 2;
1015 pOutputBuffer += 2;
1016 outputBytesRemaining -= 2;
1017 num2 = num11;
1018 }
1019 goto IL_02e9;
1020 IL_02e9:
1021 while (true)
1022 {
1023 if (IsFirstCharAscii(num2))
1024 {
1025 if (outputBytesRemaining == 0)
1026 {
1027 break;
1028 }
1030 *pOutputBuffer = (byte)num2;
1031 pInputBuffer++;
1032 pOutputBuffer++;
1033 outputBytesRemaining--;
1034 if (pInputBuffer > ptr)
1035 {
1036 goto IL_04e5;
1037 }
1038 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1039 }
1041 {
1042 while (IsSecondCharTwoUtf8Bytes(num2))
1043 {
1044 if (outputBytesRemaining < 4)
1045 {
1046 goto end_IL_0074;
1047 }
1048 Unsafe.WriteUnaligned(pOutputBuffer, ExtractTwoUtf8TwoByteSequencesFromTwoPackedUtf16Chars(num2));
1049 pInputBuffer += 2;
1050 pOutputBuffer += 4;
1051 outputBytesRemaining -= 4;
1052 if (pInputBuffer <= ptr)
1053 {
1054 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1055 if (!IsFirstCharTwoUtf8Bytes(num2))
1056 {
1057 goto IL_0074;
1058 }
1059 continue;
1060 }
1061 goto IL_04e5;
1062 }
1063 if (outputBytesRemaining < 2)
1064 {
1065 break;
1066 }
1067 Unsafe.WriteUnaligned(pOutputBuffer, (ushort)ExtractUtf8TwoByteSequenceFromFirstUtf16Char(num2));
1068 if (IsSecondCharAscii(num2))
1069 {
1070 goto IL_038f;
1071 }
1072 pInputBuffer++;
1073 pOutputBuffer += 2;
1074 outputBytesRemaining -= 2;
1075 if (pInputBuffer > ptr)
1076 {
1077 goto IL_04e5;
1078 }
1079 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1080 }
1081 while (!IsFirstCharSurrogate(num2))
1082 {
1083 if (IsSecondCharAtLeastThreeUtf8Bytes(num2) && !IsSecondCharSurrogate(num2) && outputBytesRemaining >= 6)
1084 {
1085 WriteTwoUtf16CharsAsTwoUtf8ThreeByteSequences(ref *pOutputBuffer, num2);
1086 pInputBuffer += 2;
1087 pOutputBuffer += 6;
1088 outputBytesRemaining -= 6;
1089 if (pInputBuffer <= ptr)
1090 {
1091 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1093 {
1094 goto IL_0074;
1095 }
1096 continue;
1097 }
1098 }
1099 else
1100 {
1101 if (outputBytesRemaining < 3)
1102 {
1103 goto end_IL_02e9;
1104 }
1105 WriteFirstUtf16CharAsUtf8ThreeByteSequence(ref *pOutputBuffer, num2);
1106 pInputBuffer++;
1107 pOutputBuffer += 3;
1108 outputBytesRemaining -= 3;
1109 if (!IsSecondCharAscii(num2))
1110 {
1111 goto IL_049e;
1112 }
1113 if (outputBytesRemaining == 0)
1114 {
1115 goto end_IL_02e9;
1116 }
1118 *pOutputBuffer = (byte)(num2 >> 16);
1119 pInputBuffer++;
1120 pOutputBuffer++;
1121 outputBytesRemaining--;
1122 if (pInputBuffer <= ptr)
1123 {
1124 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1126 {
1127 goto IL_0074;
1128 }
1129 continue;
1130 }
1131 }
1132 goto IL_04e5;
1133 }
1134 goto IL_04ae;
1135 IL_049e:
1136 if (pInputBuffer <= ptr)
1137 {
1138 num2 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1139 continue;
1140 }
1141 goto IL_04e5;
1142 continue;
1143 end_IL_02e9:
1144 break;
1145 }
1146 goto IL_05a7;
1147 continue;
1148 end_IL_0074:
1149 break;
1150 }
1151 break;
1152 }
1154 uint num12 = num2 & 0xFFFFu;
1155 goto IL_050b;
1156 IL_05af:
1157 pInputBufferRemaining = pInputBuffer;
1158 pOutputBufferRemaining = pOutputBuffer;
1159 OperationStatus result;
1160 return result;
1161 IL_05a7:
1162 result = OperationStatus.DestinationTooSmall;
1163 goto IL_05af;
1164 IL_05ac:
1165 result = OperationStatus.InvalidData;
1166 goto IL_05af;
1167 IL_059d:
1168 result = OperationStatus.Done;
1169 goto IL_05af;
1170 IL_050b:
1171 if (num12 <= 127)
1172 {
1173 if (outputBytesRemaining != 0)
1174 {
1175 *pOutputBuffer = (byte)num12;
1176 pInputBuffer++;
1177 pOutputBuffer++;
1178 goto IL_0599;
1179 }
1180 }
1181 else if (num12 < 2048)
1182 {
1183 if (outputBytesRemaining >= 2)
1184 {
1185 pOutputBuffer[1] = (byte)((num12 & 0x3Fu) | 0xFFFFFF80u);
1186 *pOutputBuffer = (byte)((num12 >> 6) | 0xFFFFFFC0u);
1187 pInputBuffer++;
1188 pOutputBuffer += 2;
1189 goto IL_0599;
1190 }
1191 }
1192 else
1193 {
1195 {
1196 if (num12 > 56319)
1197 {
1198 goto IL_05ac;
1199 }
1200 result = OperationStatus.NeedMoreData;
1201 goto IL_05af;
1202 }
1203 if (outputBytesRemaining >= 3)
1204 {
1205 pOutputBuffer[2] = (byte)((num12 & 0x3Fu) | 0xFFFFFF80u);
1206 pOutputBuffer[1] = (byte)(((num12 >> 6) & 0x3Fu) | 0xFFFFFF80u);
1207 *pOutputBuffer = (byte)((num12 >> 12) | 0xFFFFFFE0u);
1208 pInputBuffer++;
1209 pOutputBuffer += 3;
1210 goto IL_0599;
1211 }
1212 }
1213 goto IL_05a7;
1214 IL_04f0:
1215 if (inputLength != 0)
1216 {
1217 num12 = *pInputBuffer;
1218 goto IL_050b;
1219 }
1220 goto IL_059d;
1221 IL_0599:
1222 if (inputLength <= 1)
1223 {
1224 goto IL_059d;
1225 }
1226 goto IL_05a7;
1227 }
1228
1229 public unsafe static byte* GetPointerToFirstInvalidByte(byte* pInputBuffer, int inputLength, out int utf16CodeUnitCountAdjustment, out int scalarCountAdjustment)
1230 {
1231 nuint indexOfFirstNonAsciiByte = ASCIIUtility.GetIndexOfFirstNonAsciiByte(pInputBuffer, (uint)inputLength);
1232 pInputBuffer += indexOfFirstNonAsciiByte;
1233 inputLength -= (int)indexOfFirstNonAsciiByte;
1234 if (inputLength == 0)
1235 {
1236 utf16CodeUnitCountAdjustment = 0;
1237 scalarCountAdjustment = 0;
1238 return pInputBuffer;
1239 }
1240 int num = 0;
1241 int num2 = 0;
1242 nuint num13;
1243 if (inputLength >= 4)
1244 {
1245 byte* ptr = pInputBuffer + (uint)inputLength - 4;
1246 while (pInputBuffer <= ptr)
1247 {
1248 uint num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1249 while (true)
1250 {
1251 IL_0043:
1253 {
1254 pInputBuffer += 4;
1255 if ((nint)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *ptr) < (nint)16)
1256 {
1257 break;
1258 }
1259 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1261 {
1262 pInputBuffer = (byte*)((nuint)(pInputBuffer + 4) & ~(nuint)3u);
1263 byte* ptr2 = ptr - 12;
1265 {
1266 }
1267 uint num4;
1268 while (true)
1269 {
1270 if (Sse2.IsSupported)
1271 {
1272 num4 = (uint)Sse2.MoveMask(Sse2.LoadVector128(pInputBuffer));
1273 if (num4 != 0)
1274 {
1275 break;
1276 }
1277 goto IL_00da;
1278 }
1279 if (ASCIIUtility.AllBytesInUInt32AreAscii(*(uint*)pInputBuffer | *(uint*)(pInputBuffer + 4)))
1280 {
1281 if (ASCIIUtility.AllBytesInUInt32AreAscii(*(uint*)(pInputBuffer + (nint)2 * (nint)4) | *(uint*)(pInputBuffer + (nint)3 * (nint)4)))
1282 {
1283 goto IL_00da;
1284 }
1285 pInputBuffer += 8;
1286 }
1287 num3 = *(uint*)pInputBuffer;
1289 {
1290 pInputBuffer += 4;
1291 num3 = *(uint*)pInputBuffer;
1292 }
1293 goto IL_011e;
1294 IL_00da:
1295 pInputBuffer += 16;
1296 if (pInputBuffer > ptr2)
1297 {
1298 goto end_IL_0043;
1299 }
1300 }
1301 nuint num5 = (nuint)BitOperations.TrailingZeroCount(num4);
1302 pInputBuffer += num5;
1303 if (pInputBuffer > ptr)
1304 {
1305 goto end_IL_0428;
1306 }
1307 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1308 goto IL_013d;
1309 }
1310 }
1311 goto IL_011e;
1312 IL_011e:
1314 pInputBuffer += num6;
1315 if (ptr < pInputBuffer)
1316 {
1317 goto end_IL_0428;
1318 }
1319 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1320 goto IL_013d;
1321 IL_039e:
1322 pInputBuffer += 6;
1323 num -= 4;
1324 break;
1325 IL_013d:
1326 while (true)
1327 {
1328 uint num7 = num3;
1330 {
1331 }
1332 num3 = num7 - 32960;
1333 uint num8 = num3;
1335 {
1336 }
1337 if ((num8 & 0xC0E0u) != 0)
1338 {
1339 break;
1340 }
1342 if ((uint)(byte)num3 >= 2u)
1343 {
1345 {
1346 }
1347 while (true)
1348 {
1351 {
1352 break;
1353 }
1354 pInputBuffer += 4;
1355 num -= 2;
1356 if (pInputBuffer > ptr)
1357 {
1358 goto end_IL_0428;
1359 }
1360 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1363 {
1364 goto IL_0043;
1365 }
1366 }
1367 num--;
1368 if (UInt32ThirdByteIsAscii(num3))
1369 {
1370 if (UInt32FourthByteIsAscii(num3))
1371 {
1372 pInputBuffer += 4;
1373 goto end_IL_0043;
1374 }
1375 pInputBuffer += 3;
1376 if (pInputBuffer > ptr)
1377 {
1378 goto end_IL_0043;
1379 }
1380 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1381 continue;
1382 }
1383 pInputBuffer += 2;
1384 goto end_IL_0043;
1385 }
1386 goto IL_0521;
1387 }
1388 uint num9 = num3;
1390 {
1391 }
1392 num3 = num9 - 8388640;
1393 uint num10 = num3;
1395 {
1396 }
1397 if ((num10 & 0xC0C0F0) == 0)
1398 {
1399 while (true)
1400 {
1402 if ((num3 & 0x200F) == 0 || ((num3 - 8205) & 0x200F) == 0)
1403 {
1404 break;
1405 }
1406 while (true)
1407 {
1408 IL_024a:
1410 nint num11 = (int)num3 >> 31;
1411 pInputBuffer += 4;
1412 pInputBuffer += num11;
1413 num -= 2;
1414 ulong num12;
1415 while (true)
1416 {
1417 _ = IntPtr.Size;
1419 if ((nint)(ptr - pInputBuffer) < 5)
1420 {
1421 break;
1422 }
1423 num12 = Unsafe.ReadUnaligned<ulong>(pInputBuffer);
1424 num3 = (uint)num12;
1425 if ((num12 & 0xC0F0C0C0F0C0C0F0uL) == 9286563722648649952uL && IsUtf8ContinuationByte(in pInputBuffer[8]))
1426 {
1427 if (((int)num12 & 0x200F) == 0 || (((int)num12 - 8205) & 0x200F) == 0)
1428 {
1429 goto end_IL_0222;
1430 }
1431 num12 >>= 24;
1432 if (((uint)(int)num12 & 0x200Fu) != 0 && ((uint)((int)num12 - 8205) & 0x200Fu) != 0)
1433 {
1434 num12 >>= 24;
1435 if (((uint)(int)num12 & 0x200Fu) != 0 && ((uint)((int)num12 - 8205) & 0x200Fu) != 0)
1436 {
1437 pInputBuffer += 9;
1438 num -= 6;
1439 continue;
1440 }
1441 }
1442 goto IL_024a;
1443 }
1444 goto IL_033c;
1445 }
1446 break;
1447 IL_033c:
1448 if ((num12 & 0xC0C0F0C0C0F0L) == 141291010687200L)
1449 {
1450 if (((int)num12 & 0x200F) == 0 || (((int)num12 - 8205) & 0x200F) == 0)
1451 {
1452 goto end_IL_0222;
1453 }
1454 num12 >>= 24;
1455 if (((int)num12 & 0x200F) == 0 || (((int)num12 - 8205) & 0x200F) == 0)
1456 {
1457 continue;
1458 }
1459 goto IL_039e;
1460 }
1461 goto IL_03ac;
1462 }
1463 if (pInputBuffer > ptr)
1464 {
1465 goto end_IL_0428;
1466 }
1467 num3 = Unsafe.ReadUnaligned<uint>(pInputBuffer);
1469 {
1470 goto IL_0043;
1471 }
1472 continue;
1473 IL_03ac:
1475 {
1476 goto IL_0043;
1477 }
1478 continue;
1479 end_IL_0222:
1480 break;
1481 }
1482 }
1483 else
1484 {
1486 num3 &= 0xC0C0FFFFu;
1487 if ((int)num3 <= -2147467265)
1488 {
1489 num3 = BitOperations.RotateRight(num3, 8);
1490 if (UnicodeUtility.IsInRangeInclusive(num3, 276824080u, 343932943u))
1491 {
1492 pInputBuffer += 4;
1493 num -= 2;
1494 num2--;
1495 break;
1496 }
1497 }
1498 }
1499 goto IL_0521;
1500 continue;
1501 end_IL_0043:
1502 break;
1503 }
1504 continue;
1505 end_IL_0428:
1506 break;
1507 }
1508 num13 = (nuint)((byte*)(void*)Unsafe.ByteOffset(ref *pInputBuffer, ref *ptr) + 4);
1509 }
1510 else
1511 {
1512 num13 = (uint)inputLength;
1513 }
1514 while (num13 != 0)
1515 {
1516 uint num14 = *pInputBuffer;
1517 if ((uint)(byte)num14 < 128u)
1518 {
1519 pInputBuffer++;
1520 num13--;
1521 continue;
1522 }
1523 if (num13 < 2)
1524 {
1525 break;
1526 }
1527 uint value = pInputBuffer[1];
1528 if ((uint)(byte)num14 < 224u)
1529 {
1530 if ((uint)(byte)num14 < 194u || !IsLowByteUtf8ContinuationByte(value))
1531 {
1532 break;
1533 }
1534 pInputBuffer += 2;
1535 num--;
1536 num13 -= 2;
1537 continue;
1538 }
1539 if (num13 < 3 || (uint)(byte)num14 >= 240u)
1540 {
1541 break;
1542 }
1543 if ((byte)num14 == 224)
1544 {
1545 if (!UnicodeUtility.IsInRangeInclusive(value, 160u, 191u))
1546 {
1547 break;
1548 }
1549 }
1550 else if ((byte)num14 == 237)
1551 {
1552 if (!UnicodeUtility.IsInRangeInclusive(value, 128u, 159u))
1553 {
1554 break;
1555 }
1556 }
1558 {
1559 break;
1560 }
1561 if (!IsUtf8ContinuationByte(in pInputBuffer[2]))
1562 {
1563 break;
1564 }
1565 pInputBuffer += 3;
1566 num -= 2;
1567 num13 -= 3;
1568 }
1569 goto IL_0521;
1570 IL_0521:
1571 utf16CodeUnitCountAdjustment = num;
1572 scalarCountAdjustment = num2;
1573 return pInputBuffer;
1574 }
1575}
static readonly bool IsLittleEndian
static sbyte ReverseEndianness(sbyte value)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static int TrailingZeroCount(int value)
static uint RotateRight(uint value, int offset)
static uint RotateLeft(uint value, int offset)
static Vector128< byte > Create(byte value)
Definition Vector128.cs:138
static unsafe Vector128< byte > CreateScalarUnsafe(byte value)
Definition Vector128.cs:829
static ulong ConvertToUInt64(Vector128< ulong > value)
Definition Sse2.cs:24
static unsafe Vector128< sbyte > LoadVector128(sbyte *address)
Definition Sse2.cs:582
static int MoveMask(Vector128< sbyte > value)
Definition Sse2.cs:772
static uint ConvertToUInt32(Vector128< uint > value)
Definition Sse2.cs:512
static unsafe void StoreScalar(double *address, Vector128< double > source)
Definition Sse2.cs:1172
static Vector128< byte > PackUnsignedSaturate(Vector128< short > left, Vector128< short > right)
Definition Sse2.cs:892
static new bool IsSupported
Definition Sse2.cs:60
static bool TestZ(Vector128< sbyte > left, Vector128< sbyte > right)
Definition Sse41.cs:692
static unsafe nuint GetIndexOfFirstNonAsciiByte(byte *pBuffer, nuint bufferLength)
static uint CountNumberOfLeadingAsciiBytesFromUInt32WithSomeNonAsciiData(uint value)
static void WidenFourAsciiBytesToUtf16AndWriteToBuffer(ref char outputBuffer, uint value)
static unsafe nuint WidenAsciiToUtf16(byte *pAsciiBuffer, char *pUtf16Buffer, nuint elementCount)
static bool AllBytesInUInt32AreAscii(uint value)
static unsafe nuint NarrowUtf16ToAscii(char *pUtf16Buffer, byte *pAsciiBuffer, nuint elementCount)
static bool IsSurrogateCodePoint(uint value)
static bool IsInRangeInclusive(uint value, uint lowerBound, uint upperBound)
static bool AllCharsInUInt32AreAscii(uint value)
static bool AllCharsInUInt64AreAscii(ulong value)
static bool UInt32BeginsWithValidUtf8TwoByteSequenceLittleEndian(uint value)
static bool UInt32FourthByteIsAscii(uint value)
static unsafe byte * GetPointerToFirstInvalidByte(byte *pInputBuffer, int inputLength, out int utf16CodeUnitCountAdjustment, out int scalarCountAdjustment)
static bool IsFirstCharAscii(uint value)
static uint ExtractCharsFromFourByteSequence(uint value)
static unsafe OperationStatus TranscodeToUtf8(char *pInputBuffer, int inputLength, byte *pOutputBuffer, int outputBytesRemaining, out char *pInputBufferRemaining, out byte *pOutputBufferRemaining)
static uint ExtractFourUtf8BytesFromSurrogatePair(uint value)
static uint ToLittleEndian(uint value)
static bool UInt32BeginsWithUtf8ThreeByteMask(uint value)
static uint ExtractUtf8TwoByteSequenceFromFirstUtf16Char(uint value)
static uint ExtractCharFromFirstTwoByteSequence(uint value)
static uint ExtractCharFromFirstThreeByteSequence(uint value)
static bool IsSecondCharSurrogate(uint value)
static uint ExtractTwoCharsPackedFromTwoAdjacentTwoByteSequences(uint value)
static bool IsFirstCharTwoUtf8Bytes(uint value)
static bool IsFirstCharAtLeastThreeUtf8Bytes(uint value)
static bool UInt32FirstByteIsAscii(uint value)
static bool IsUtf8ContinuationByte(in byte value)
static bool IsSecondCharAtLeastThreeUtf8Bytes(uint value)
static bool IsLowByteUtf8ContinuationByte(uint value)
static bool IsWellFormedUtf16SurrogatePair(uint value)
static bool UInt32EndsWithValidUtf8TwoByteSequenceLittleEndian(uint value)
static bool IsFirstCharSurrogate(uint value)
static uint ExtractTwoUtf8TwoByteSequencesFromTwoPackedUtf16Chars(uint value)
static void WriteTwoUtf16CharsAsTwoUtf8ThreeByteSequences(ref byte outputBuffer, uint value)
static bool UInt32BeginsWithUtf8TwoByteMask(uint value)
static unsafe OperationStatus TranscodeToUtf16(byte *pInputBuffer, int inputLength, char *pOutputBuffer, int outputCharsRemaining, out byte *pInputBufferRemaining, out char *pOutputBufferRemaining)
static bool UInt32ThirdByteIsAscii(uint value)
static bool IsSecondCharTwoUtf8Bytes(uint value)
static void WriteFirstUtf16CharAsUtf8ThreeByteSequence(ref byte outputBuffer, uint value)
static bool IsSecondCharAscii(uint value)
static bool UInt32BeginsWithOverlongUtf8TwoByteSequence(uint value)
static bool UInt32BeginsWithUtf8FourByteMask(uint value)
static bool UInt32SecondByteIsAscii(uint value)
static int Size
Definition IntPtr.cs:21