internal static int GetUtf8FromText(ReadOnlySpan <char> text, Span <byte> dest)
        {
            try
            {
#if BUILDING_INBOX_LIBRARY
                return(s_utf8Encoding.GetBytes(text, dest));
#else
                if (text.IsEmpty)
                {
                    return(0);
                }

                unsafe
                {
                    fixed(char *charPtr = text)
                    fixed(byte *destPtr = dest)
                    {
                        return(s_utf8Encoding.GetBytes(charPtr, text.Length, destPtr, dest.Length));
                    }
                }
#endif
            }
            catch (EncoderFallbackException ex)
            {
                // We want to be consistent with the exception being thrown
                // so the user only has to catch a single exception.
                // Since we already throw ArgumentException when validating other arguments,
                // using that exception for failure to encode invalid UTF-16 chars as well.
                // Therefore, wrapping the EncoderFallbackException around an ArgumentException.
                throw ThrowHelper.GetArgumentException_ReadInvalidUTF16(ex);
            }
        }