Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ WriteCDataSectionNoFlush()

unsafe int System.Xml.XmlUtf8RawTextWriter.WriteCDataSectionNoFlush ( string text,
int index,
int count,
out bool needWriteNewLine )
inlineprotectedinherited

Definition at line 2685 of file XmlUtf8RawTextWriter.cs.

2686 {
2687 needWriteNewLine = false;
2688 if (count == 0)
2689 {
2690 return -1;
2691 }
2692 fixed (char* ptr = text)
2693 {
2694 char* ptr2 = ptr + index;
2695 byte[] bufBytes = _bufBytes;
2696 fixed (byte[] array = bufBytes)
2697 {
2698 byte* ptr3 = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
2699 char* ptr4 = ptr2;
2700 char* ptr5 = ptr2 + count;
2701 char* ptr6 = ptr4;
2702 byte* ptr7 = ptr3 + _bufPos;
2703 int num = 0;
2704 while (true)
2705 {
2706 byte* ptr8 = ptr7 + (ptr5 - ptr4);
2707 if (ptr8 > ptr3 + _bufLen)
2708 {
2709 ptr8 = ptr3 + _bufLen;
2710 }
2711 while (ptr7 < ptr8 && XmlCharType.IsAttributeValueChar((char)(num = *ptr4)) && num != 93 && num <= 127)
2712 {
2713 *ptr7 = (byte)num;
2714 ptr7++;
2715 ptr4++;
2716 }
2717 if (ptr4 >= ptr5)
2718 {
2719 break;
2720 }
2721 if (ptr7 >= ptr8)
2722 {
2723 _bufPos = (int)(ptr7 - ptr3);
2724 return (int)(ptr4 - ptr6);
2725 }
2726 switch (num)
2727 {
2728 case 62:
2729 if (_hadDoubleBracket && ptr7[-1] == 93)
2730 {
2733 }
2734 *ptr7 = 62;
2735 ptr7++;
2736 break;
2737 case 93:
2738 if (ptr7[-1] == 93)
2739 {
2740 _hadDoubleBracket = true;
2741 }
2742 else
2743 {
2744 _hadDoubleBracket = false;
2745 }
2746 *ptr7 = 93;
2747 ptr7++;
2748 break;
2749 case 13:
2750 if (_newLineHandling == NewLineHandling.Replace)
2751 {
2752 if (ptr4 + 1 < ptr5 && ptr4[1] == '\n')
2753 {
2754 ptr4++;
2755 }
2756 _bufPos = (int)(ptr7 - ptr3);
2757 needWriteNewLine = true;
2758 return (int)(ptr4 - ptr6);
2759 }
2760 *ptr7 = (byte)num;
2761 ptr7++;
2762 break;
2763 case 10:
2764 if (_newLineHandling == NewLineHandling.Replace)
2765 {
2766 _bufPos = (int)(ptr7 - ptr3);
2767 needWriteNewLine = true;
2768 return (int)(ptr4 - ptr6);
2769 }
2770 *ptr7 = (byte)num;
2771 ptr7++;
2772 break;
2773 case 9:
2774 case 34:
2775 case 38:
2776 case 39:
2777 case 60:
2778 *ptr7 = (byte)num;
2779 ptr7++;
2780 break;
2781 default:
2782 if (XmlCharType.IsSurrogate(num))
2783 {
2785 ptr4 += 2;
2786 }
2787 else if (num <= 127 || num >= 65534)
2788 {
2790 ptr4++;
2791 }
2792 else
2793 {
2795 ptr4++;
2796 }
2797 continue;
2798 }
2799 ptr4++;
2800 }
2801 _bufPos = (int)(ptr7 - ptr3);
2802 }
2803 return -1;
2804 }
2805 }
static unsafe byte * RawStartCData(byte *pDst)
unsafe byte * InvalidXmlChar(int ch, byte *pDst, bool entitize)
static unsafe byte * RawEndCData(byte *pDst)
static unsafe byte * EncodeMultibyteUTF8(int ch, byte *pDst)
static unsafe byte * EncodeSurrogate(char *pSrc, char *pSrcEnd, byte *pDst)

References System.Xml.XmlUtf8RawTextWriter._bufBytes, System.Xml.XmlUtf8RawTextWriter._bufLen, System.Xml.XmlUtf8RawTextWriter._bufPos, System.Xml.XmlUtf8RawTextWriter._hadDoubleBracket, System.Xml.XmlUtf8RawTextWriter._newLineHandling, System.array, System.count, System.Xml.Dictionary, System.Xml.XmlUtf8RawTextWriter.EncodeMultibyteUTF8(), System.Xml.XmlUtf8RawTextWriter.EncodeSurrogate(), System.index, System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(), System.Xml.XmlCharType.IsAttributeValueChar(), System.Xml.XmlCharType.IsSurrogate(), System.Xml.XmlUtf8RawTextWriter.RawEndCData(), System.Xml.XmlUtf8RawTextWriter.RawStartCData(), and System.text.

Referenced by System.Xml.XmlUtf8RawTextWriter.WriteCDataSectionAsync().