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

◆ GetChars() [2/6]

unsafe override int System.Text.SBCSCodePageEncoding.GetChars ( byte * bytes,
int byteCount,
char * chars,
int charCount,
System::Text::DecoderNLS decoder )
inlinevirtual

Reimplemented from System.Text.EncodingNLS.

Definition at line 473 of file SBCSCodePageEncoding.cs.

474 {
476 bool flag = false;
477 byte* ptr = bytes + byteCount;
478 byte* ptr2 = bytes;
479 char* ptr3 = chars;
480 DecoderReplacementFallback decoderReplacementFallback = null;
481 if (decoder == null)
482 {
483 decoderReplacementFallback = base.DecoderFallback as DecoderReplacementFallback;
484 flag = base.DecoderFallback is InternalDecoderBestFitFallback;
485 }
486 else
487 {
488 decoderReplacementFallback = decoder.Fallback as DecoderReplacementFallback;
489 flag = decoder.Fallback is InternalDecoderBestFitFallback;
490 }
491 if (flag || (decoderReplacementFallback != null && decoderReplacementFallback.MaxCharCount == 1))
492 {
493 char c = decoderReplacementFallback?.DefaultString[0] ?? '?';
494 if (charCount < byteCount)
495 {
496 ThrowCharsOverflow(decoder, charCount < 1);
497 ptr = bytes + charCount;
498 }
499 while (bytes < ptr)
500 {
501 char c2;
502 if (flag)
503 {
504 if (arrayBytesBestFit == null)
505 {
507 }
509 }
510 else
511 {
512 c2 = _mapBytesToUnicode[(int)(*bytes)];
513 }
514 bytes++;
515 if (c2 == '\ufffd')
516 {
517 *chars = c;
518 }
519 else
520 {
521 *chars = c2;
522 }
523 chars++;
524 }
525 if (decoder != null)
526 {
527 decoder.m_bytesUsed = (int)(bytes - ptr2);
528 }
529 return (int)(chars - ptr3);
530 }
531 DecoderFallbackBuffer decoderFallbackBuffer = null;
532 byte[] array = new byte[1];
533 char* ptr4 = chars + charCount;
534 DecoderFallbackBufferHelper decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(null);
535 while (bytes < ptr)
536 {
537 char c3 = _mapBytesToUnicode[(int)(*bytes)];
538 bytes++;
539 if (c3 == '\ufffd')
540 {
541 if (decoderFallbackBuffer == null)
542 {
543 decoderFallbackBuffer = ((decoder != null) ? decoder.FallbackBuffer : base.DecoderFallback.CreateFallbackBuffer());
544 decoderFallbackBufferHelper = new DecoderFallbackBufferHelper(decoderFallbackBuffer);
545 decoderFallbackBufferHelper.InternalInitialize(ptr - byteCount, ptr4);
546 }
547 array[0] = *(bytes - 1);
548 if (!decoderFallbackBufferHelper.InternalFallback(array, bytes, ref chars))
549 {
550 bytes--;
551 decoderFallbackBufferHelper.InternalReset();
552 ThrowCharsOverflow(decoder, bytes == ptr2);
553 break;
554 }
555 }
556 else
557 {
558 if (chars >= ptr4)
559 {
560 bytes--;
561 ThrowCharsOverflow(decoder, bytes == ptr2);
562 break;
563 }
564 *chars = c3;
565 chars++;
566 }
567 }
568 if (decoder != null)
569 {
570 decoder.m_bytesUsed = (int)(bytes - ptr2);
571 }
572 return (int)(chars - ptr3);
573 }
new DecoderFallbackBuffer FallbackBuffer
Definition DecoderNLS.cs:24
DecoderFallback DecoderFallback
Definition Encoding.cs:480

References System.Text.SBCSCodePageEncoding._mapBytesToUnicode, System.array, System.Text.BaseCodePageEncoding.arrayBytesBestFit, System.byteCount, System.bytes, System.charCount, System.chars, System.Text.BaseCodePageEncoding.CheckMemorySection(), System.Text.DecoderReplacementFallback.DefaultString, System.Text.DecoderFallbackBufferHelper.InternalFallback(), System.Text.DecoderFallbackBufferHelper.InternalInitialize(), System.Text.DecoderFallbackBufferHelper.InternalReset(), System.Text.DecoderReplacementFallback.MaxCharCount, System.Text.SBCSCodePageEncoding.ReadBestFitTable(), and System.Text.EncodingNLS.ThrowCharsOverflow().