unsafe public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
{
if (chars == null)
throw new ArgumentNullException(nameof(chars));
if (charIndex < 0)
throw new ArgumentOutOfRangeException(nameof(charIndex), SR.ValueMustBeNonNegative);
if (charIndex > chars.Length)
throw new ArgumentOutOfRangeException(nameof(charIndex), SR.Format(SR.OffsetExceedsBufferSize, chars.Length));
if (charCount < 0)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.ValueMustBeNonNegative);
if (charCount > chars.Length - charIndex)
throw new ArgumentOutOfRangeException(nameof(charCount), SR.Format(SR.SizeExceedsRemainingBufferSpace, chars.Length - charIndex));
if (bytes == null)
throw new ArgumentNullException(nameof(bytes));
if (byteIndex < 0)
throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.ValueMustBeNonNegative);
if (byteIndex > bytes.Length)
throw new ArgumentOutOfRangeException(nameof(byteIndex), SR.Format(SR.OffsetExceedsBufferSize, bytes.Length));
int byteCount = GetByteCount(chars, charIndex, charCount);
if (byteCount < 0 || byteCount > bytes.Length - byteIndex)
throw new ArgumentException(SR.XmlArrayTooSmall, nameof(bytes));
if (charCount > 0)
{
fixed (byte* _char2val = s_char2val)
{
fixed (byte* _bytes = &bytes[byteIndex])
{
fixed (char* _chars = &chars[charIndex])
{
char* pch = _chars;
char* pchMax = _chars + charCount;
byte* pb = _bytes;
while (pch < pchMax)
{
char pch0 = pch[0];
char pch1 = pch[1];
if ((pch0 | pch1) >= 128)
throw new FormatException(SR.Format(SR.XmlInvalidBinHexSequence, new string(pch, 0, 2), charIndex + (int)(pch - _chars)));
byte d1 = _char2val[pch0];
byte d2 = _char2val[pch1];
if ((d1 | d2) == 0xFF)
throw new FormatException(SR.Format(SR.XmlInvalidBinHexSequence, new string(pch, 0, 2), charIndex + (int)(pch - _chars)));
pb[0] = (byte)((d1 << 4) + d2);
pch += 2;
pb++;
}
}
}
}
}
return byteCount;
}
#if NO