-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Encoding
Milestone
Description
From dotnet/aspnetcore#8374 (comment)
Cross encoding compare
namespace System.Text
{
public partial class ASCIIEncoding : Encoding
{
public static bool IsEquivalentOrdinal(
ReadOnlySpan<char> chars,
ReadOnlySpan<byte> asciiBytes);
}
}
This is method to test whether a sequence of ascii bytes is the same as a string; without having to first convert the bytes to a sting and allocate and then use string equality. (e.g. compare ascii bytes to a UTF-16 string)
Used in dotnet/aspnetcore#8374 to drop steady state string allocations to zero (as previous materialized strings can be reused when they match the on-wire bytes)
e.g.
Could extend with an bool ignoreCase = false
if desired, however that is not required for this particular use case.
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-System.Text.Encoding