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

◆ GetChars() [5/7]

unsafe override int System.Text.Base64Encoding.GetChars ( byte[] bytes,
int byteIndex,
int byteCount,
char[] chars,
int charIndex )
inline

Definition at line 319 of file Base64Encoding.cs.

320 {
321 if (bytes == null)
322 {
323 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("bytes"));
324 }
325 if (byteIndex < 0)
326 {
327 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.ValueMustBeNonNegative));
328 }
329 if (byteIndex > bytes.Length)
330 {
331 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, bytes.Length)));
332 }
333 if (byteCount < 0)
334 {
335 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteCount", System.SR.ValueMustBeNonNegative));
336 }
337 if (byteCount > bytes.Length - byteIndex)
338 {
339 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("byteCount", System.SR.Format(System.SR.SizeExceedsRemainingBufferSpace, bytes.Length - byteIndex)));
340 }
342 if (chars == null)
343 {
344 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("chars"));
345 }
346 if (charIndex < 0)
347 {
348 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.ValueMustBeNonNegative));
349 }
350 if (charIndex > chars.Length)
351 {
352 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException("charIndex", System.SR.Format(System.SR.OffsetExceedsBufferSize, chars.Length)));
353 }
355 {
357 }
358 if (byteCount > 0)
359 {
360 fixed (char* ptr6 = &"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".GetPinnableReference())
361 {
362 fixed (byte* ptr = &bytes[byteIndex])
363 {
364 fixed (char* ptr4 = &chars[charIndex])
365 {
366 byte* ptr2 = ptr;
367 byte* ptr3 = ptr2 + byteCount - 3;
368 char* ptr5 = ptr4;
369 while (ptr2 <= ptr3)
370 {
371 *ptr5 = ptr6[*ptr2 >> 2];
372 ptr5[1] = ptr6[((*ptr2 & 3) << 4) | (ptr2[1] >> 4)];
373 ptr5[2] = ptr6[((ptr2[1] & 0xF) << 2) | (ptr2[2] >> 6)];
374 ptr5[3] = ptr6[ptr2[2] & 0x3F];
375 ptr2 += 3;
376 ptr5 += 4;
377 }
378 if (ptr2 - ptr3 == 2)
379 {
380 *ptr5 = ptr6[*ptr2 >> 2];
381 ptr5[1] = ptr6[(*ptr2 & 3) << 4];
382 ptr5[2] = '=';
383 ptr5[3] = '=';
384 }
385 else if (ptr2 - ptr3 == 1)
386 {
387 *ptr5 = ptr6[*ptr2 >> 2];
388 ptr5[1] = ptr6[((*ptr2 & 3) << 4) | (ptr2[1] >> 4)];
389 ptr5[2] = ptr6[(ptr2[1] & 0xF) << 2];
390 ptr5[3] = '=';
391 }
392 }
393 }
394 }
395 }
396 return charCount;
397 }
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string ValueMustBeNonNegative
Definition SR.cs:296
static string SizeExceedsRemainingBufferSpace
Definition SR.cs:324
static string OffsetExceedsBufferSize
Definition SR.cs:322
static string XmlArrayTooSmall
Definition SR.cs:348
Definition SR.cs:7
override int GetCharCount(byte[] bytes, int index, int count)

References System.byteCount, System.byteIndex, System.bytes, System.charCount, System.charIndex, System.chars, System.Runtime.Serialization.Dictionary, System.SR.Format(), System.Text.Base64Encoding.GetCharCount(), System.SR.OffsetExceedsBufferSize, System.SR.SizeExceedsRemainingBufferSpace, System.Runtime.Serialization.DiagnosticUtility.ExceptionUtility.ThrowHelperError(), System.SR.ValueMustBeNonNegative, and System.SR.XmlArrayTooSmall.

Referenced by System.Xml.XmlUTF8NodeWriter.InternalWriteBase64TextAsync().