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

◆ GetCharsWithFallback() [3/3]

unsafe override int System.Text.ASCIIEncoding.GetCharsWithFallback ( ReadOnlySpan< byte > bytes,
int originalBytesLength,
Span< char > chars,
int originalCharsLength,
DecoderNLS decoder )
inlinesealedprotectedvirtualinherited

Reimplemented from System.Text.Encoding.

Definition at line 386 of file ASCIIEncoding.cs.

387 {
388 if (((decoder == null) ? base.DecoderFallback : decoder.Fallback) is DecoderReplacementFallback { MaxCharCount: 1 } decoderReplacementFallback)
389 {
390 char c = decoderReplacementFallback.DefaultString[0];
391 int num = Math.Min(bytes.Length, chars.Length);
392 int num2 = 0;
393 fixed (byte* ptr2 = &MemoryMarshal.GetReference(bytes))
394 {
395 fixed (char* ptr = &MemoryMarshal.GetReference(chars))
396 {
397 while (num2 < num)
398 {
399 ptr[num2++] = c;
400 if (num2 < num)
401 {
402 num2 += (int)ASCIIUtility.WidenAsciiToUtf16(ptr2 + num2, ptr + num2, (uint)(num - num2));
403 }
404 }
405 }
406 }
407 bytes = bytes.Slice(num);
408 chars = chars.Slice(num);
409 }
410 if (bytes.IsEmpty)
411 {
412 return originalCharsLength - chars.Length;
413 }
414 return base.GetCharsWithFallback(bytes, originalBytesLength, chars, originalCharsLength, decoder);
415 }

References System.bytes, System.chars, System.Text.DecoderNLS.Fallback, System.Math.Min(), and System.Text.ASCIIUtility.WidenAsciiToUtf16().

Referenced by System.Text.ASCIIEncoding.GetCharsCommon().