示例#1
0
        private int FindFirstCharacterToEncode(ReadOnlySpan <char> span)
        {
            int originalLength = span.Length;

            while (!span.IsEmpty)
            {
                if (!TryGetNextScalarValue(span, out int scalarValue) || !_isScalarAllowed(scalarValue))
                {
                    return(originalLength - span.Length); // couldn't extract scalar or failed predicate
                }

                span = span.Slice(UnicodeUtility.GetUtf16SequenceLength((uint)scalarValue));
            }

            return(-1); // entire span was consumed
        }