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

◆ WriteCommentOrPi()

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

Definition at line 1086 of file XmlEncodedRawTextWriter.cs.

1087 {
1088 if (text.Length == 0)
1089 {
1090 if (_bufPos >= _bufLen)
1091 {
1092 FlushBuffer();
1093 }
1094 return;
1095 }
1096 fixed (char* ptr2 = text)
1097 {
1098 char[] bufChars = _bufChars;
1099 fixed (char[] array = bufChars)
1100 {
1101 char* ptr = (char*)((bufChars != null && array.Length != 0) ? Unsafe.AsPointer(ref array[0]) : null);
1102 char* ptr3 = ptr2;
1103 char* ptr4 = ptr2 + text.Length;
1104 char* ptr5 = ptr + _bufPos;
1105 int num = 0;
1106 while (true)
1107 {
1108 char* ptr6 = ptr5 + (ptr4 - ptr3);
1109 if (ptr6 > ptr + _bufLen)
1110 {
1111 ptr6 = ptr + _bufLen;
1112 }
1113 while (ptr5 < ptr6 && XmlCharType.IsTextChar((char)(num = *ptr3)) && num != stopChar)
1114 {
1115 *ptr5 = (char)num;
1116 ptr5++;
1117 ptr3++;
1118 }
1119 if (ptr3 >= ptr4)
1120 {
1121 break;
1122 }
1123 if (ptr5 >= ptr6)
1124 {
1125 _bufPos = (int)(ptr5 - ptr);
1126 FlushBuffer();
1127 ptr5 = ptr + 1;
1128 continue;
1129 }
1130 switch (num)
1131 {
1132 case 45:
1133 *ptr5 = '-';
1134 ptr5++;
1135 if (num == stopChar && (ptr3 + 1 == ptr4 || ptr3[1] == '-'))
1136 {
1137 *ptr5 = ' ';
1138 ptr5++;
1139 }
1140 break;
1141 case 63:
1142 *ptr5 = '?';
1143 ptr5++;
1144 if (num == stopChar && ptr3 + 1 < ptr4 && ptr3[1] == '>')
1145 {
1146 *ptr5 = ' ';
1147 ptr5++;
1148 }
1149 break;
1150 case 93:
1151 *ptr5 = ']';
1152 ptr5++;
1153 break;
1154 case 13:
1155 if (_newLineHandling == NewLineHandling.Replace)
1156 {
1157 if (ptr3 + 1 < ptr4 && ptr3[1] == '\n')
1158 {
1159 ptr3++;
1160 }
1162 }
1163 else
1164 {
1165 *ptr5 = (char)num;
1166 ptr5++;
1167 }
1168 break;
1169 case 10:
1170 if (_newLineHandling == NewLineHandling.Replace)
1171 {
1173 break;
1174 }
1175 *ptr5 = (char)num;
1176 ptr5++;
1177 break;
1178 case 9:
1179 case 38:
1180 case 60:
1181 *ptr5 = (char)num;
1182 ptr5++;
1183 break;
1184 default:
1185 if (XmlCharType.IsSurrogate(num))
1186 {
1188 ptr3 += 2;
1189 }
1190 else if (num <= 127 || num >= 65534)
1191 {
1193 ptr3++;
1194 }
1195 else
1196 {
1197 *ptr5 = (char)num;
1198 ptr5++;
1199 ptr3++;
1200 }
1201 continue;
1202 }
1203 ptr3++;
1204 }
1205 _bufPos = (int)(ptr5 - ptr);
1206 }
1207 }
1208 }
unsafe char * InvalidXmlChar(int ch, char *pDst, bool entitize)
static unsafe char * EncodeSurrogate(char *pSrc, char *pSrcEnd, char *pDst)

References System.Xml.XmlEncodedRawTextWriter._bufChars, System.Xml.XmlEncodedRawTextWriter._bufLen, System.Xml.XmlEncodedRawTextWriter._bufPos, System.Xml.XmlEncodedRawTextWriter._newLineHandling, System.array, System.Xml.Dictionary, System.Xml.XmlEncodedRawTextWriter.EncodeSurrogate(), System.Xml.XmlEncodedRawTextWriter.FlushBuffer(), System.Xml.XmlEncodedRawTextWriter.InvalidXmlChar(), System.Xml.XmlCharType.IsSurrogate(), System.Xml.XmlCharType.IsTextChar(), System.text, and System.Xml.XmlEncodedRawTextWriter.WriteNewLine().

Referenced by System.Xml.XmlEncodedRawTextWriter.WriteComment(), System.Xml.XmlEncodedRawTextWriter.WriteProcessingInstruction(), and System.Xml.HtmlEncodedRawTextWriter.WriteProcessingInstruction().