public unsafe void HandleFallback (ref EncoderFallbackBuffer buffer,
char* chars, ref int charIndex, ref int charCount,
byte* bytes, ref int byteIndex, ref int byteCount, object state)
{
if (buffer == null)
buffer = EncoderFallback.CreateFallbackBuffer ();
if (charCount > 1 && (Char.IsSurrogate (chars [charIndex]) && Char.IsSurrogate (chars [charIndex + 1]))) {
buffer.Fallback (chars [charIndex], chars [charIndex + 1], charIndex);
charIndex++;
charCount--;
}
else
buffer.Fallback (chars [charIndex], charIndex);
char [] tmp = new char [buffer.Remaining];
int idx = 0;
while (buffer.Remaining > 0)
tmp [idx++] = buffer.GetNextChar ();
fixed (char* tmparr = tmp) {
var outbytes = bytes == null ? null : bytes + byteIndex;
var len = state == null ?
GetBytes(tmparr, tmp.Length, outbytes, byteCount)
: GetBytesInternal(tmparr, tmp.Length, outbytes, byteCount, true, state);
byteIndex += len;
byteCount -= len;
}
}