Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions csharp/PhoneNumbers/PhoneNumberUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -869,8 +869,10 @@ public static string GetCountryMobileToken(int countryCallingCode)
/// should be stripped from the number. If this is false, they
/// will be left unchanged in the number.</param>
/// <returns>The normalized string version of the phone number.</returns>
#if !(NET5_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER)
private static string NormalizeHelper(string number, Func<char, char> normalizationReplacements, bool removeNonMatches)
Comment on lines 869 to 873
=> NormalizeHelper(new StringBuilder(number), normalizationReplacements, removeNonMatches).ToString();
#endif

private static StringBuilder NormalizeHelper(StringBuilder number, Func<char, char> normalizationReplacements, bool removeNonMatches)
{
Expand Down
9 changes: 9 additions & 0 deletions csharp/PhoneNumbers/PhoneNumberUtil.net.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,15 @@ private static void NormalizeHelper(ref Span<char> span,
}
}

private static string NormalizeHelper(string number, Func<char, char> normalizationReplacements, bool removeNonMatches)
{
if (number.Length == 0) return string.Empty;
Span<char> result = stackalloc char[number.Length];
var resultLength = 0;
NormalizeHelper(ref result, ref resultLength, number, normalizationReplacements, removeNonMatches);
Comment on lines +611 to +614
return new string(result.Slice(0, resultLength));
}

private static bool IsValidAlphaPhone(string number)
{
for (int alpha = 0, i = 0; i < number.Length; i++)
Expand Down
Loading