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

◆ InternalReadChars()

int System.IO.BinaryReader.InternalReadChars ( Span< char > buffer)
inlineprivateinherited

Definition at line 337 of file BinaryReader.cs.

338 {
339 int num = 0;
340 while (!buffer.IsEmpty)
341 {
342 int num2 = buffer.Length;
343 if (_2BytesPerChar)
344 {
345 num2 <<= 1;
346 }
347 if (num2 > 1 && !(_decoder is DecoderNLS { HasState: false }))
348 {
349 num2--;
350 if (_2BytesPerChar && num2 > 2)
351 {
352 num2 -= 2;
353 }
354 }
355 ReadOnlySpan<byte> bytes;
356 if (_isMemoryStream)
357 {
358 MemoryStream memoryStream = (MemoryStream)_stream;
359 int start = memoryStream.InternalGetPosition();
360 num2 = memoryStream.InternalEmulateRead(num2);
361 bytes = new ReadOnlySpan<byte>(memoryStream.InternalGetBuffer(), start, num2);
362 }
363 else
364 {
365 if (_charBytes == null)
366 {
367 _charBytes = new byte[128];
368 }
369 if (num2 > 128)
370 {
371 num2 = 128;
372 }
373 num2 = _stream.Read(_charBytes, 0, num2);
374 bytes = new ReadOnlySpan<byte>(_charBytes, 0, num2);
375 }
376 if (bytes.IsEmpty)
377 {
378 break;
379 }
380 int chars = _decoder.GetChars(bytes, buffer, flush: false);
381 buffer = buffer.Slice(chars);
382 num += chars;
383 }
384 return num;
385 }
readonly Decoder _decoder
readonly Stream _stream
readonly bool _2BytesPerChar
readonly bool _isMemoryStream
int Read(byte[] buffer, int offset, int count)
int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)

References System.IO.BinaryReader._2BytesPerChar, System.IO.BinaryReader._charBytes, System.IO.BinaryReader._decoder, System.IO.BinaryReader._isMemoryStream, System.IO.BinaryReader._stream, System.buffer, System.bytes, System.chars, System.Text.Decoder.GetChars(), System.IO.MemoryStream.InternalEmulateRead(), System.IO.MemoryStream.InternalGetBuffer(), System.IO.MemoryStream.InternalGetPosition(), System.IO.Stream.Read(), and System.start.

Referenced by System.IO.BinaryReader.Read(), System.IO.BinaryReader.Read(), and System.IO.BinaryReader.ReadChars().