public void ToBase62Chars8_WithOverlappingInputAndOutputSpans_ShouldReturnExpectedOutput(string text, string base62String)
        {
            Span <byte> bytes = stackalloc byte[11];

            System.Text.Encoding.UTF8.GetBytes(text, bytes);
            Base62.ToBase62Chars8(bytes, bytes);
            var outputString = System.Text.Encoding.UTF8.GetString(bytes);

            Assert.Equal(base62String, outputString);
        }
        public void ToBase62Chars8_Regularly_ShouldReturnExpectedOutput(string text, string base62String)
        {
            var         bytes       = System.Text.Encoding.UTF8.GetBytes(text);
            Span <byte> outputChars = stackalloc byte[base62String.Length];

            Base62.ToBase62Chars8(bytes, outputChars);
            var outputString = System.Text.Encoding.UTF8.GetString(outputChars);

            Assert.Equal(base62String, outputString);
        }
        /// <summary>
        /// <para>
        /// Outputs an 11-character alphanumeric string representation of the given ID.
        /// </para>
        /// <para>
        /// Throws if the output span is too short.
        /// </para>
        /// </summary>
        /// <param name="id">The ID to encode.</param>
        /// <param name="bytes">At least 11 bytes, to write the alphanumeric representation to.</param>
        public static void GetAlphanumeric(ulong id, Span <byte> bytes)
        {
            if (bytes.Length < 11)
            {
                throw new IndexOutOfRangeException("At least 11 output bytes are required.");
            }

            // Abuse the caller's output span as input space
            BinaryPrimitives.WriteUInt64BigEndian(bytes, id);

            Base62.ToBase62Chars8(bytes, bytes);
        }