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

◆ DecodeBytes()

unsafe int System.Net.Mime.QuotedPrintableStream.DecodeBytes ( byte[] buffer,
int offset,
int count )
inline

Implements System.Net.Mime.IEncodableStream.

Definition at line 163 of file QuotedPrintableStream.cs.

164 {
165 fixed (byte* ptr = buffer)
166 {
167 byte* ptr2 = ptr + offset;
168 byte* ptr3 = ptr2;
169 byte* ptr4 = ptr2;
170 byte* ptr5 = ptr2 + count;
171 if (ReadState.IsEscaped)
172 {
173 if (ReadState.Byte == -1)
174 {
175 if (count == 1)
176 {
177 ReadState.Byte = *ptr3;
178 return 0;
179 }
180 if (*ptr3 != 13 || ptr3[1] != 10)
181 {
182 byte b = HexDecodeMap[*ptr3];
183 byte b2 = HexDecodeMap[ptr3[1]];
184 if (b == byte.MaxValue)
185 {
186 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b));
187 }
188 if (b2 == byte.MaxValue)
189 {
190 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b2));
191 }
192 *(ptr4++) = (byte)((b << 4) + b2);
193 }
194 ptr3 += 2;
195 }
196 else
197 {
198 if (ReadState.Byte != 13 || *ptr3 != 10)
199 {
200 byte b3 = HexDecodeMap[ReadState.Byte];
201 byte b4 = HexDecodeMap[*ptr3];
202 if (b3 == byte.MaxValue)
203 {
204 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b3));
205 }
206 if (b4 == byte.MaxValue)
207 {
208 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b4));
209 }
210 *(ptr4++) = (byte)((b3 << 4) + b4);
211 }
212 ptr3++;
213 }
214 ReadState.IsEscaped = false;
215 ReadState.Byte = -1;
216 }
217 while (ptr3 < ptr5)
218 {
219 if (*ptr3 != 61)
220 {
221 *(ptr4++) = *(ptr3++);
222 continue;
223 }
224 long num = ptr5 - ptr3;
225 if (num != 1)
226 {
227 if (num != 2)
228 {
229 if (ptr3[1] != 13 || ptr3[2] != 10)
230 {
231 byte b5 = HexDecodeMap[ptr3[1]];
232 byte b6 = HexDecodeMap[ptr3[2]];
233 if (b5 == byte.MaxValue)
234 {
235 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b5));
236 }
237 if (b6 == byte.MaxValue)
238 {
239 throw new FormatException(System.SR.Format(System.SR.InvalidHexDigit, b6));
240 }
241 *(ptr4++) = (byte)((b5 << 4) + b6);
242 }
243 ptr3 += 3;
244 continue;
245 }
246 ReadState.Byte = ptr3[1];
247 }
248 ReadState.IsEscaped = true;
249 break;
250 }
251 return (int)(ptr4 - ptr2);
252 }
253 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string InvalidHexDigit
Definition SR.cs:46
Definition SR.cs:7

References System.buffer, System.count, System.SR.Format(), System.Net.Mime.QuotedPrintableStream.HexDecodeMap, System.SR.InvalidHexDigit, and System.offset.