public static bool TryDecodeCodePoint(Span<byte> buffer, out UnicodeCodePoint codePoint, out int encodedBytes)
{
if (buffer.Length == 0)
{
codePoint = default(UnicodeCodePoint);
encodedBytes = default(int);
return false;
}
byte first = buffer[0];
if (!TryGetFirstByteCodePointValue(first, out codePoint, out encodedBytes))
return false;
if (buffer.Length < encodedBytes)
return false;
// TODO: Should we manually inline this for values 1-4 or will compiler do this for us?
for (int i = 1; i < encodedBytes; i++)
{
if (!TryReadCodePointByte(buffer[i], ref codePoint))
return false;
}
return true;
}