return false;
}
}
+
+ /// <summary>
+ /// Validates that the value is well-formed UTF-8.
+ /// </summary>
+ /// <param name="value">The <see cref="ReadOnlySpan{T}"/> string.</param>
+ /// <returns><c>true</c> if value is well-formed UTF-8, <c>false</c> otherwise.</returns>
+ public static unsafe bool IsValid(ReadOnlySpan<byte> value) =>
+ Utf8Utility.GetIndexOfFirstInvalidUtf8Sequence(value, out _) < 0;
}
}
public static System.Buffers.OperationStatus ToUtf16(System.ReadOnlySpan<byte> source, System.Span<char> destination, out int bytesRead, out int charsWritten, bool replaceInvalidSequences = true, bool isFinalBlock = true) { throw null; }
public static bool TryWrite(System.Span<byte> destination, [System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute("destination")] ref System.Text.Unicode.Utf8.TryWriteInterpolatedStringHandler handler, out int bytesWritten) { throw null; }
public static bool TryWrite(System.Span<byte> destination, IFormatProvider? provider, [System.Runtime.CompilerServices.InterpolatedStringHandlerArgumentAttribute("destination", "provider")] ref System.Text.Unicode.Utf8.TryWriteInterpolatedStringHandler handler, out int bytesWritten) { throw null; }
+ public static bool IsValid(System.ReadOnlySpan<byte> value) { throw null; }
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
[System.Runtime.CompilerServices.InterpolatedStringHandlerAttribute]
public ref struct TryWriteInterpolatedStringHandler
Assert.Equal(expectedRetVal, actualRetVal);
Assert.Equal(expectedRuneCount, actualRuneCount);
Assert.Equal(expectedSurrogatePairCount, actualSurrogatePairCount);
+
+ Assert.True(Utf8.IsValid(boundedMemory.Span) == (expectedRetVal < 0));
}
private static Lazy<GetPointerToFirstInvalidByteDel> CreateGetPointerToFirstInvalidByteFn()