int GetChars(byte[] bytes, int byteIndex, int byteCount,
char[] chars, int charIndex,
ref DecoderFallbackBuffer buffer)
{
#endif
if (bytes == null)
{
throw new ArgumentNullException("bytes");
}
if (chars == null)
{
throw new ArgumentNullException("chars");
}
if (byteIndex < 0 || byteIndex > bytes.Length)
{
throw new ArgumentOutOfRangeException("byteIndex", _("ArgRange_Array"));
}
if (byteCount < 0 || byteCount > (bytes.Length - byteIndex))
{
throw new ArgumentOutOfRangeException("byteCount", _("ArgRange_Array"));
}
if (charIndex < 0 || charIndex > chars.Length)
{
throw new ArgumentOutOfRangeException("charIndex", _("ArgRange_Array"));
}
if ((chars.Length - charIndex) < byteCount)
{
throw new ArgumentException(_("Arg_InsufficientSpace"));
}
int count = byteCount;
while (count-- > 0)
{
char c = (char)bytes [byteIndex++];
if (c < '\x80')
{
chars [charIndex++] = c;
}
else
{
#if NET_2_0
if (buffer == null)
{
buffer = DecoderFallback.CreateFallbackBuffer();
}
buffer.Fallback(bytes, byteIndex);
while (buffer.Remaining > 0)
{
chars [charIndex++] = buffer.GetNextChar();
}
#else
chars [charIndex++] = '?';
#endif
}
}
return(byteCount);
}