private unsafe int InternalReadChars(char[] buffer, int index, int count)
{
int num = 0;
int charCount = count;
if (this.m_charBytes == null)
{
this.m_charBytes = new byte[0x80];
}
while (charCount > 0)
{
int num3 = 0;
num = charCount;
UTF8Encoding.UTF8Decoder decoder = this.m_decoder as UTF8Encoding.UTF8Decoder;
if (((decoder != null) && decoder.HasState) && (num > 1))
{
num--;
}
if (this.m_2BytesPerChar)
{
num = num << 1;
}
if (num > 0x80)
{
num = 0x80;
}
int position = 0;
byte[] charBytes = null;
if (this.m_isMemoryStream)
{
MemoryStream stream = this.m_stream as MemoryStream;
position = stream.InternalGetPosition();
num = stream.InternalEmulateRead(num);
charBytes = stream.InternalGetBuffer();
}
else
{
num = this.m_stream.Read(this.m_charBytes, 0, num);
charBytes = this.m_charBytes;
}
if (num == 0)
{
return(count - charCount);
}
fixed(byte *numRef = charBytes)
{
fixed(char *chRef = buffer)
{
num3 = this.m_decoder.GetChars(numRef + position, num, chRef + index, charCount, false);
}
}
charCount -= num3;
index += num3;
}
return(count - charCount);
}