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

◆ DrainLeftoverDataForGetChars()

int System.Text.DecoderNLS.DrainLeftoverDataForGetChars ( ReadOnlySpan< byte > bytes,
Span< char > chars,
out int bytesConsumed )
inlinepackageinherited

Definition at line 226 of file DecoderNLS.cs.

227 {
228 Span<byte> span = stackalloc byte[4];
229 span = span.Slice(0, ConcatInto(GetLeftoverData(), bytes, span));
230 int charsWritten = 0;
231 bool flag = false;
232 Rune value;
233 int bytesConsumed2;
234 switch (_encoding.DecodeFirstRune(span, out value, out bytesConsumed2))
235 {
236 case OperationStatus.Done:
237 if (!value.TryEncodeToUtf16(chars, out charsWritten))
238 {
239 break;
240 }
241 goto IL_00aa;
242 case OperationStatus.NeedMoreData:
243 if (MustFlush)
244 {
245 goto default;
246 }
247 flag = true;
248 goto IL_00aa;
249 default:
250 {
251 if (base.FallbackBuffer.Fallback(span.Slice(0, bytesConsumed2).ToArray(), -_leftoverByteCount) && !_fallbackBuffer.TryDrainRemainingDataForGetChars(chars, out charsWritten))
252 {
253 break;
254 }
255 goto IL_00aa;
256 }
257 IL_00aa:
258 bytesConsumed = bytesConsumed2 - _leftoverByteCount;
259 if (flag)
260 {
261 SetLeftoverData(span);
262 }
263 else
264 {
266 }
267 return charsWritten;
268 }
269 _encoding.ThrowCharsOverflow(this, nothingDecoded: true);
270 throw null;
271 }
bool TryDrainRemainingDataForGetChars(Span< char > chars, out int charsWritten)
static int ConcatInto(ReadOnlySpan< byte > srcLeft, ReadOnlySpan< byte > srcRight, Span< byte > dest)
void SetLeftoverData(ReadOnlySpan< byte > bytes)
ReadOnlySpan< byte > GetLeftoverData()
readonly Encoding _encoding
Definition DecoderNLS.cs:8
DecoderFallbackBuffer _fallbackBuffer
Definition Decoder.cs:9
virtual OperationStatus DecodeFirstRune(ReadOnlySpan< byte > bytes, out Rune value, out int bytesConsumed)
Definition Encoding.cs:1109

References System.Text.DecoderNLS._encoding, System.Text.Decoder._fallbackBuffer, System.Text.DecoderNLS._leftoverByteCount, System.bytes, System.chars, System.Text.DecoderNLS.ClearLeftoverData(), System.Text.DecoderNLS.ConcatInto(), System.Text.Encoding.DecodeFirstRune(), System.Text.DecoderNLS.GetLeftoverData(), System.Text.DecoderNLS.MustFlush, System.Text.DecoderNLS.SetLeftoverData(), System.Span< T >.Slice(), System.Text.Encoding.ThrowCharsOverflow(), System.Text.DecoderFallbackBuffer.TryDrainRemainingDataForGetChars(), and System.value.

Referenced by System.Text.Encoding.GetCharsWithFallback().