-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[API Proposal]: ReadOnlySpan<char>
overloads for StringNormalizationExtensions
#87757
Comments
Tagging subscribers to this area: @dotnet/area-system-globalization Issue DetailsBackground and motivationIf we try to verify that the string represented by API Proposalnamespace System;
public static class StringNormalizationExtensions {
+ public static bool IsNormalized(this ReadOnlySpan<char> strInput, NormalizationForm normalizationForm = NormalizationForm.FormC);
+ public static bool TryNormalize(this ReadOnlySpan<char> strInput, Span<char> destination, out int charsWritten, NormalizationForm normalizationForm = NormalizationForm.FormC);
} API UsageReadOnlySpan<char> partOfhugeArray = hugeArray.AsSpan(start, length);
if (!partOfhugeArray.IsNormalized())
throw new Exception("Text must be Unicode normalized.");
/// ... Alternative DesignsNo response RisksNo response
|
ReadOnlySpan<char>
overloads for StringNormalizationExtensions
@udaken I made a few edits to the proposal and hope that works for you. |
namespace System;
public static partial class StringNormalizationExtensions
{
public static bool IsNormalized(this ReadOnlySpan<char> source, NormalizationForm normalizationForm = NormalizationForm.FormC);
public static bool TryNormalize(this ReadOnlySpan<char> source, Span<char> destination, out int charsWritten, NormalizationForm normalizationForm = NormalizationForm.FormC);
public static int GetNormalizedLength(this ReadOnlySpan<char> source, NormalizationForm normalizationForm = NormalizationForm.FormC);
} |
Edited by @tarekgh
Background and motivation
If we try to verify that the string represented by
ReadOnlySpan<char>
is Unicode normalized, we currently have to turn it into astring
once.Overloading for
ReadOnlySpan<char>
is needed to reduce allocation.API Proposal
Original Proposal - Alternative Proposal
API Usage
No response
Risks
No response
The text was updated successfully, but these errors were encountered: