-
Notifications
You must be signed in to change notification settings - Fork 335
ISXB-449 fix for turkish letter i #1664
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| using System; | ||
| using System.Text; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using Unity.Collections; | ||
| using UnityEngine.InputSystem.Layouts; | ||
|
|
@@ -558,15 +559,15 @@ private static bool StringMatches(Substring str, InternedString matchTo) | |
| return true; // Wildcard at end of string so rest is matched. | ||
|
|
||
| ++posInStr; | ||
| nextChar = char.ToLower(str[posInStr]); | ||
| nextChar = char.ToLower(str[posInStr], CultureInfo.InvariantCulture); | ||
|
|
||
| while (posInMatchTo < matchToLength && matchToLowerCase[posInMatchTo] != nextChar) | ||
| ++posInMatchTo; | ||
|
|
||
| if (posInMatchTo == matchToLength) | ||
| return false; // Matched all the way to end of matchTo but there's more in str after the wildcard. | ||
| } | ||
| else if (char.ToLower(nextChar) != matchToLowerCase[posInMatchTo]) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above comment |
||
| else if (char.ToLower(nextChar, CultureInfo.InvariantCulture) != matchToLowerCase[posInMatchTo]) | ||
| { | ||
| return false; | ||
| } | ||
|
|
@@ -1107,7 +1108,7 @@ private static bool MatchPathComponent(string component, string path, ref int in | |
| } | ||
|
|
||
| var charInComponent = component[indexInComponent]; | ||
| if (charInComponent == nextCharInPath || char.ToLower(charInComponent) == char.ToLower(nextCharInPath)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and again as above |
||
| if (charInComponent == nextCharInPath || char.ToLower(charInComponent, CultureInfo.InvariantCulture) == char.ToLower(nextCharInPath, CultureInfo.InvariantCulture)) | ||
| { | ||
| ++indexInComponent; | ||
| ++indexInPath; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -418,7 +418,7 @@ public static bool CharacterSeparatedListsHaveAtLeastOneCommonElement(string fir | |
| var first = firstList[startIndexInFirst + i]; | ||
| var second = secondList[startIndexInSecond + i]; | ||
|
|
||
| if (char.ToLower(first) != char.ToLower(second)) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and one more as above |
||
| if (char.ToLowerInvariant(first) != char.ToLowerInvariant(second)) | ||
| { | ||
| isMatch = false; | ||
| break; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could a fix be to convert to pass CultureInfo.InvariantCulture
E.g.
nextChar = char.ToLower(str[posInStr], CultureInfo.InvariantCulture);
or (if version allowed) :
nextChar = char.ToLowerInvariant(str[posInStr]);
and a few lines down
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToUpperInvariantis recommended here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/best-practices-stringsI believe going in the other direction (lower) creates issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks James. I missed that comment in the Microsoft documents. I mainly suggested this as it seemed we were missing the invariantCulture altogether but agree we may need the upper case for a more complete fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToUpperInvariantis using Invariant Culture rules so that should be enough without needing to passCultureInfo.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lyndon-unity @jamesmcgill I just updated whole branch to only use culture invariant char comparisons, this fixes the bug without changing to ToUpperInvariant(). I would suggest closing the ticket (as the bug is fixed) at this state and creating a new refactoring ticket for clean up the string ToLowerInvariant -> ToUpperInvariant situation. Maybe it even makes sense to do it in a bigger scale where we look at all our string storing and comparison situation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is a good step and fixes the current but. We have captured the future step in a task here:
https://jira.unity3d.com/browse/ISX-1380