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

◆ WriteCommentOrPi()

unsafe void System.Xml.XmlUtf8RawTextWriter.WriteCommentOrPi ( string text,
int stopChar )
inlineprotectedinherited

Definition at line 885 of file XmlUtf8RawTextWriter.cs.

886 {
887 if (text.Length == 0)
888 {
889 if (_bufPos >= _bufLen)
890 {
891 FlushBuffer();
892 }
893 return;
894 }
895 fixed (char* ptr2 = text)
896 {
897 byte[] bufBytes = _bufBytes;
898 fixed (byte[] array = bufBytes)
899 {
900 byte* ptr = (byte*)((bufBytes != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
901 char* ptr3 = ptr2;
902 char* ptr4 = ptr2 + text.Length;
903 byte* ptr5 = ptr + _bufPos;
904 int num = 0;
905 while (true)
906 {
907 byte* ptr6 = ptr5 + (ptr4 - ptr3);
908 if (ptr6 > ptr + _bufLen)
909 {
910 ptr6 = ptr + _bufLen;
911 }
912 while (ptr5 < ptr6 && XmlCharType.IsTextChar((char)(num = *ptr3)) && num != stopChar && num <= 127)
913 {
914 *ptr5 = (byte)num;
915 ptr5++;
916 ptr3++;
917 }
918 if (ptr3 >= ptr4)
919 {
920 break;
921 }
922 if (ptr5 >= ptr6)
923 {
924 _bufPos = (int)(ptr5 - ptr);
925 FlushBuffer();
926 ptr5 = ptr + 1;
927 continue;
928 }
929 switch (num)
930 {
931 case 45:
932 *ptr5 = 45;
933 ptr5++;
934 if (num == stopChar && (ptr3 + 1 == ptr4 || ptr3[1] == '-'))
935 {
936 *ptr5 = 32;
937 ptr5++;
938 }
939 break;
940 case 63:
941 *ptr5 = 63;
942 ptr5++;
943 if (num == stopChar && ptr3 + 1 < ptr4 && ptr3[1] == '>')
944 {
945 *ptr5 = 32;
946 ptr5++;
947 }
948 break;
949 case 93:
950 *ptr5 = 93;
951 ptr5++;
952 break;
953 case 13:
954 if (_newLineHandling == NewLineHandling.Replace)
955 {
956 if (ptr3 + 1 < ptr4 && ptr3[1] == '\n')
957 {
958 ptr3++;
959 }
961 }
962 else
963 {
964 *ptr5 = (byte)num;
965 ptr5++;
966 }
967 break;
968 case 10:
969 if (_newLineHandling == NewLineHandling.Replace)
970 {
972 break;
973 }
974 *ptr5 = (byte)num;
975 ptr5++;
976 break;
977 case 9:
978 case 38:
979 case 60:
980 *ptr5 = (byte)num;
981 ptr5++;
982 break;
983 default:
984 if (XmlCharType.IsSurrogate(num))
985 {
987 ptr3 += 2;
988 }
989 else if (num <= 127 || num >= 65534)
990 {
992 ptr3++;
993 }
994 else
995 {
997 ptr3++;
998 }
999 continue;
1000 }
1001 ptr3++;
1002 }
1003 _bufPos = (int)(ptr5 - ptr);
1004 }
1005 }
1006 }
unsafe byte * WriteNewLine(byte *pDst)
unsafe byte * InvalidXmlChar(int ch, byte *pDst, bool entitize)
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._newLineHandling, System.array, System.Xml.Dictionary, System.Xml.XmlUtf8RawTextWriter.EncodeMultibyteUTF8(), System.Xml.XmlUtf8RawTextWriter.EncodeSurrogate(), System.Xml.XmlUtf8RawTextWriter.FlushBuffer(), System.Xml.XmlUtf8RawTextWriter.InvalidXmlChar(), System.Xml.XmlCharType.IsSurrogate(), System.Xml.XmlCharType.IsTextChar(), System.text, and System.Xml.XmlUtf8RawTextWriter.WriteNewLine().

Referenced by System.Xml.XmlUtf8RawTextWriter.WriteComment(), System.Xml.XmlUtf8RawTextWriter.WriteProcessingInstruction(), and System.Xml.HtmlUtf8RawTextWriter.WriteProcessingInstruction().