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

◆ GetBytes() [2/9]

unsafe override int System.Text.ISCIIEncoding.GetBytes ( char * chars,
int charCount,
byte * bytes,
int byteCount,
System::Text::EncoderNLS baseEncoder )
inlinevirtual

Reimplemented from System.Text.EncodingNLS.

Definition at line 513 of file ISCIIEncoding.cs.

514 {
515 ISCIIEncoder iSCIIEncoder = (ISCIIEncoder)baseEncoder;
516 EncodingByteBuffer encodingByteBuffer = new EncodingByteBuffer(this, iSCIIEncoder, bytes, byteCount, chars, charCount);
517 int num = _defaultCodePage;
518 bool flag = false;
519 if (iSCIIEncoder != null)
520 {
521 num = iSCIIEncoder.currentCodePage;
522 flag = iSCIIEncoder.bLastVirama;
523 if (iSCIIEncoder.charLeftOver > '\0')
524 {
525 encodingByteBuffer.Fallback(iSCIIEncoder.charLeftOver);
526 flag = false;
527 }
528 }
529 while (encodingByteBuffer.MoreData)
530 {
531 char nextChar = encodingByteBuffer.GetNextChar();
532 if (nextChar < '\u00a0')
533 {
534 if (!encodingByteBuffer.AddByte((byte)nextChar))
535 {
536 break;
537 }
538 flag = false;
539 continue;
540 }
541 if (nextChar < '\u0901' || nextChar > '൯')
542 {
543 if (flag && (nextChar == '\u200c' || nextChar == '\u200d'))
544 {
545 if (nextChar == '\u200c')
546 {
547 if (!encodingByteBuffer.AddByte(232))
548 {
549 break;
550 }
551 }
552 else if (!encodingByteBuffer.AddByte(233))
553 {
554 break;
555 }
556 flag = false;
557 }
558 else
559 {
561 flag = false;
562 }
563 continue;
564 }
565 int num2 = s_UnicodeToIndicChar[nextChar - 2305];
566 byte b = (byte)num2;
567 int num3 = 0xF & (num2 >> 8);
568 int num4 = 0xF000 & num2;
569 if (num2 == 0)
570 {
572 flag = false;
573 continue;
574 }
575 if (num3 != num)
576 {
577 if (!encodingByteBuffer.AddByte(239, (byte)((uint)num3 | 0x40u)))
578 {
579 break;
580 }
581 num = num3;
582 }
583 if (!encodingByteBuffer.AddByte(b, (num4 != 0) ? 1 : 0))
584 {
585 break;
586 }
587 flag = b == 232;
588 if (num4 != 0 && !encodingByteBuffer.AddByte(s_SecondIndicByte[num4 >> 12]))
589 {
590 break;
591 }
592 }
593 if (num != _defaultCodePage && (iSCIIEncoder == null || iSCIIEncoder.MustFlush))
594 {
595 if (encodingByteBuffer.AddByte(239, (byte)((uint)_defaultCodePage | 0x40u)))
596 {
597 num = _defaultCodePage;
598 }
599 else
600 {
601 encodingByteBuffer.GetNextChar();
602 }
603 flag = false;
604 }
605 if (iSCIIEncoder != null && bytes != null)
606 {
607 if (!encodingByteBuffer.fallbackBufferHelper.bUsedEncoder)
608 {
610 }
614 }
615 return encodingByteBuffer.Count;
616 }
static readonly byte[] s_SecondIndicByte
static readonly int[] s_UnicodeToIndicChar

References System.Text.ISCIIEncoding._defaultCodePage, System.byteCount, System.bytes, System.charCount, System.chars, System.Runtime.Serialization.Dictionary, System.Text.ISCIIEncoding.s_SecondIndicByte, and System.Text.ISCIIEncoding.s_UnicodeToIndicChar.

Referenced by System.Text.ISCIIEncoding.GetByteCount().