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

◆ GetCharCountWithFallback() [3/3]

unsafe int System.Text.Encoding.GetCharCountWithFallback ( ReadOnlySpan< byte > bytes,
int originalBytesLength,
DecoderNLS decoder )
inlineprivateinherited

Definition at line 1380 of file Encoding.cs.

1381 {
1382 fixed (byte* ptr = &MemoryMarshal.GetReference(bytes))
1383 {
1384 DecoderFallbackBuffer decoderFallbackBuffer = DecoderFallbackBuffer.CreateAndInitialize(this, decoder, originalBytesLength);
1385 int num = 0;
1386 Rune value;
1387 int bytesConsumed;
1388 while (DecodeFirstRune(bytes, out value, out bytesConsumed) != OperationStatus.NeedMoreData || decoder == null || decoder.MustFlush)
1389 {
1390 int num2 = decoderFallbackBuffer.InternalFallbackGetCharCount(bytes, bytesConsumed);
1391 num += num2;
1392 if (num < 0)
1393 {
1395 }
1396 bytes = bytes.Slice(bytesConsumed);
1397 if (!bytes.IsEmpty)
1398 {
1399 num2 = GetCharCountFast((byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(bytes)), bytes.Length, null, out bytesConsumed);
1400 num += num2;
1401 if (num < 0)
1402 {
1404 }
1405 bytes = bytes.Slice(bytesConsumed);
1406 }
1407 if (bytes.IsEmpty)
1408 {
1409 break;
1410 }
1411 }
1412 return num;
1413 }
1414 }
static void ThrowConversionOverflow()
Definition Encoding.cs:1084
virtual OperationStatus DecodeFirstRune(ReadOnlySpan< byte > bytes, out Rune value, out int bytesConsumed)
Definition Encoding.cs:1109
virtual unsafe int GetCharCountFast(byte *pBytes, int bytesLength, DecoderFallback fallback, out int bytesConsumed)
Definition Encoding.cs:1342

References System.bytes, System.Text.DecoderFallbackBuffer.CreateAndInitialize(), System.Text.Encoding.DecodeFirstRune(), System.Runtime.Serialization.Dictionary, System.Text.Encoding.GetCharCountFast(), System.Text.DecoderNLS.MustFlush, System.Text.Encoding.ThrowConversionOverflow(), and System.value.