private static int GetNextUnicodeScalarValueFromUtf16Surrogate(ReadOnlySpan<char> input, ref int index)
{
// invariants
- Debug.Assert(input.Length >= 1);
- Debug.Assert(char.IsSurrogate(input[0]));
+ Debug.Assert(input.Length - index >= 1);
+ Debug.Assert(char.IsSurrogate(input[index]));
- if (input.Length <= 1)
+ if (input.Length - index <= 1)
{
// not enough characters remaining to resurrect the original scalar value
return UnicodeReplacementChar;
}
- char leadingSurrogate = input[0];
- char trailingSurrogate = input[1];
+ char leadingSurrogate = input[index];
+ char trailingSurrogate = input[index + 1];
if (!char.IsSurrogatePair(leadingSurrogate, trailingSurrogate))
{
yield return new object[] { char.ConvertFromUtf32(144308), "𣎴" };
yield return new object[] { "\uD800\uDC00", "𐀀" };
yield return new object[] { "a\uD800\uDC00b", "a𐀀b" };
+ yield return new object[] { "\uD83D\uDE01\uD83D\uDE02\uD83D\uDE03", "😁😂😃" };
+ yield return new object[] { "a\uD83D\uDE01\uD83D\uDE02\uD83D\uDE03b", "a😁😂😃b" };
// High BMP non-chars
yield return new object[] { "\uFFFD", "\uFFFD" };