public Utf8EncodedCodePoint(char character) : this()
{
if (char.IsSurrogate(character))
{
throw new ArgumentOutOfRangeException("character", "Surrogate characters are not allowed");
}
UnicodeCodePoint codePoint = (UnicodeCodePoint)(uint)character;
unsafe
{
fixed (byte* encodedData = &_byte0)
{
var buffer = new Span<byte>(encodedData, 4);
if (!Utf8Encoder.TryEncodeCodePoint(codePoint, buffer, out _length))
{
// TODO: Change exception type
throw new Exception("Internal error: this should never happen as codePoint is within acceptable range and is not surrogate");
}
}
}
}