Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

implement StartsWith and EndsWith as calls to CompareString for sliced string #26481

Closed
wants to merge 1 commit into from

Conversation

adamsitnik
Copy link
Member

No description provided.


if (length == 0) return true;
return Interop.Globalization.StartsWith(_sortHandle, b, length, a, length, options);
return false;
Copy link

@kevingosse kevingosse Sep 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can make this assumption in the non-ordinal case.

Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR");

 string str1 = "œ";
 string str2 = "oe";

Console.WriteLine(str1.StartsWith(str2, StringComparison.CurrentCulture));

This should print true even though str2.Length > str1.Length

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's say that this was not my best idea ;p

@adamsitnik adamsitnik closed this Sep 3, 2019
@adamsitnik adamsitnik deleted the fasterStartsWith branch September 3, 2019 06:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants