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

◆ DecodeBytes()

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

Implements System.Net.Mime.IEncodableStream.

Definition at line 256 of file Base64Stream.cs.

257 {
258 fixed (byte* ptr = buffer)
259 {
260 byte* ptr2 = ptr + offset;
261 byte* ptr3 = ptr2;
262 byte* ptr4 = ptr2;
263 byte* ptr5 = ptr2 + count;
264 while (ptr3 < ptr5)
265 {
266 if (*ptr3 == 13 || *ptr3 == 10 || *ptr3 == 61 || *ptr3 == 32 || *ptr3 == 9)
267 {
268 ptr3++;
269 continue;
270 }
271 byte b = Base64DecodeMap[*ptr3];
272 if (b == byte.MaxValue)
273 {
274 throw new FormatException(System.SR.MailBase64InvalidCharacter);
275 }
276 switch (ReadState.Pos)
277 {
278 case 0:
279 ReadState.Val = (byte)(b << 2);
280 ReadState.Pos++;
281 break;
282 case 1:
283 *(ptr4++) = (byte)(ReadState.Val + (b >> 4));
284 ReadState.Val = (byte)(b << 4);
285 ReadState.Pos++;
286 break;
287 case 2:
288 *(ptr4++) = (byte)(ReadState.Val + (b >> 2));
289 ReadState.Val = (byte)(b << 6);
290 ReadState.Pos++;
291 break;
292 case 3:
293 *(ptr4++) = (byte)(ReadState.Val + b);
294 ReadState.Pos = 0;
295 break;
296 }
297 ptr3++;
298 }
299 return (int)(ptr4 - ptr2);
300 }
301 }
static ReadOnlySpan< byte > Base64DecodeMap
static string MailBase64InvalidCharacter
Definition SR.cs:30
Definition SR.cs:7

References System.Net.Base64Stream.Base64DecodeMap, System.buffer, System.count, System.SR.MailBase64InvalidCharacter, and System.offset.

Referenced by System.Net.Base64Stream.ReadAsyncResult.CompleteRead(), and System.Net.Base64Stream.Read().