You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CompareInfo.IsSuffix sometimes incorrectly splits collation elements and returns 'true' #43897
This sample prints idx = -1, isSuffix = True. These return values are inconsistent with respect to each other. If IsSuffix returns true, then IndexOf must return a non-negative value. It's the contrapositive of the code comment at:
Note: This sample uses CompareOptions.None. The other linked issue considers non-default CompareOptions arguments.
That is right. but the root cause the same which is coming from the optimization of this case. it is ok to keep both issues or close one and add the extra information to the other.
I've confirmed that usearch_first returns -1 for this particular case, while the first element returned by ucol_next(pSourceIterator) returns UCOL_IGNORABLE and hence the "optimized" version of the code assumes that the first character (\u0600) can be ignored and later returns true
I've also tried it with .NET Core 3.1 on Windows to see what NLS has to say:
And for NLS it returns 1 and true.
Which makes be confused.
@GrabYourPitchforks@tarekgh In a perfect world, where there are no Unicode bugs, what should be the expected result and why?
note that I expect this will happen with other codepoints (e.g. \u0601 too). I have some theory around these but let's wait if anyone officially reply the bug.
I don't know why usearch_first() returns -1 for you. The StringSearch/SearchIterator classes have several options for how to deal with ignorables and combining marks etc. at the edges of a match. I suspect that there is optional behavior on top of collation element comparison responsible for rejecting the match.
I am able to get -1 for a small repro without any custom settings. @tarekgh@GrabYourPitchforks should I file a bug for usearch_first then?
@adamsitnik I don't think this is a bug in ICU. I am seeing U+0600 is one of the characters that can be combined with the following characters which change the search operation https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt. Looks by design to ICU. This is similar to \r\n case. That is my understanding but I cannot claim I am expert in that :-)
I have looked deeply at this issue, and I am seeing the underlying problem is coming from ICU and not from our code.
When using ICU and comparing the two strings x and \u0600x, it returns the result indicating the two strings are equal which is correct. The reason is the character \u0600 is ignorable character according to Unicode Standard. But when try to search for x in the string \u0600x using ICU APIs like usearch_search or usearch_last, it returns -1 which is wrong.
I have reported the issue to ICU through the ticket. I mentioned the details in the ticket and the possible root cause of this problem.
The reason is, in the first case we search forward which cause the processing encounter \u0600 first causing it to fallback to call ICU. In the second case we find the match (in our optimized code path) before hitting \u0600 and we'll not call ICU at all in such case.
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This issue will now be closed since it had been marked no-recent-activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.
Activity
tarekgh commentedon Oct 27, 2020
#40803
GrabYourPitchforks commentedon Oct 27, 2020
Note: This sample uses
CompareOptions.None. The other linked issue considers non-defaultCompareOptionsarguments.tarekgh commentedon Oct 27, 2020
That is right. but the root cause the same which is coming from the optimization of this case. it is ok to keep both issues or close one and add the extra information to the other.
adamsitnik commentedon Oct 30, 2020
#40803 is not related to the "optimizaiton", this issue most probably is. I think it's best to keep both of them open until we fix them.
adamsitnik commentedon Oct 30, 2020
I've confirmed that
usearch_firstreturns-1for this particular case, while the first element returned byucol_next(pSourceIterator)returnsUCOL_IGNORABLEand hence the "optimized" version of the code assumes that the first character (\u0600) can be ignored and later returns trueI've also tried it with .NET Core 3.1 on Windows to see what NLS has to say:
And for NLS it returns
1andtrue.Which makes be confused.
@GrabYourPitchforks @tarekgh In a perfect world, where there are no Unicode bugs, what should be the expected result and why?
adamsitnik commentedon Nov 4, 2020
@GrabYourPitchforks I've raised a question in the ICU bug tracker: https://unicode-org.atlassian.net/browse/ICU-21375
tarekgh commentedon Nov 4, 2020
note that I expect this will happen with other codepoints (e.g.
\u0601too). I have some theory around these but let's wait if anyone officially reply the bug.adamsitnik commentedon Nov 20, 2020
My question got answered by one of the ICU members:
So
StartsWithworks as expected?I am able to get
-1for a small repro without any custom settings. @tarekgh @GrabYourPitchforks should I file a bug forusearch_firstthen?tarekgh commentedon Nov 20, 2020
@adamsitnik I don't think this is a bug in ICU. I am seeing
U+0600is one of the characters that can be combined with the following characters which change the search operation https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt. Looks by design to ICU. This is similar to\r\ncase. That is my understanding but I cannot claim I am expert in that :-)6 remaining items
tarekgh commentedon Aug 4, 2021
I have looked deeply at this issue, and I am seeing the underlying problem is coming from ICU and not from our code.
When using ICU and comparing the two strings
xand\u0600x, it returns the result indicating the two strings are equal which is correct. The reason is the character\u0600is ignorable character according to Unicode Standard. But when try to search forxin the string\u0600xusing ICU APIs likeusearch_searchorusearch_last, it returns-1which is wrong.I have reported the issue to ICU through the ticket. I mentioned the details in the ticket and the possible root cause of this problem.
Note:
In .NET, the problem shows up when doing:
but will not show up if we do
The reason is, in the first case we search forward which cause the processing encounter
\u0600first causing it to fallback to call ICU. In the second case we find the match (in our optimized code path) before hitting\u0600and we'll not call ICU at all in such case.dotnet-policy-service commentedon Feb 16, 2026
Due to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
dotnet-policy-service commentedon Mar 2, 2026
This issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.