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
[iOS] Implement IgnoreSymbols for CompreInfo in managed code (#120462)
Implementation of `CompareOptions.IgnoreSymbols` for `IndexOf`, `IsPrefix`, `IsSuffix`, `Compare` on iOS. Because ObjectiveC string APIs (https://developer.apple.com/documentation/foundation/nsstring/compareoptions?language=objc) don't provide a direct alternative to `IgnoreSymbols` option, we filter the symbols from the strings in the managed code and after returning from native, we re-calculate the original index and length.
The implementation works in a following:
1. Preprocess the source and search strings by removing the symbols.
2. Invoke the native API for comparison.
3. Map the range from preprocessed source string back to the original string to get the index and length.
---------
Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copy file name to clipboardExpand all lines: docs/design/features/globalization-hybrid-mode.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,7 @@ Due to these differences, the exact result of string compariso on Apple platform
30
30
31
31
The number of `CompareOptions` and `NSStringCompareOptions` combinations are limited. Originally supported combinations can be found [here for CompareOptions](https://learn.microsoft.com/dotnet/api/system.globalization.compareoptions) and [here for NSStringCompareOptions](https://developer.apple.com/documentation/foundation/nsstringcompareoptions).
32
32
33
-
-`IgnoreSymbols` is not supported because there is no equivalent in native api. Throws `PlatformNotSupportedException`.
33
+
-`IgnoreSymbols` is supported by filtering ignorable symbols on the managed side before invoking the native API.
34
34
35
35
-`IgnoreKanaType` is implemented using [`kCFStringTransformHiraganaKatakana`](https://developer.apple.com/documentation/corefoundation/kcfstringtransformhiraganakatakana?language=objc) then comparing strings.
36
36
@@ -71,10 +71,6 @@ The number of `CompareOptions` and `NSStringCompareOptions` combinations are lim
71
71
72
72
`CompareOptions.IgnoreWidth` is mapped to `NSStringCompareOptions.NSWidthInsensitiveSearch | NSStringCompareOptions.NSLiteralSearch`
73
73
74
-
- All combinations that contain below `CompareOptions` always throw `PlatformNotSupportedException`:
75
-
76
-
`IgnoreSymbols`
77
-
78
74
## String starts with / ends with
79
75
80
76
Affected public APIs:
@@ -91,7 +87,7 @@ Apple Native API does not expose locale-sensitive endsWith/startsWith function.
91
87
92
88
-`IgnoreSymbols`
93
89
94
-
As there is no IgnoreSymbols equivalent in NSStringCompareOptions all `CompareOptions` combinations that include `IgnoreSymbols` throw `PlatformNotSupportedException`
90
+
Supported by filtering ignorable symbols on the managed side prior to comparison using native API.
95
91
96
92
## String indexing
97
93
@@ -129,7 +125,7 @@ Not covered case:
129
125
130
126
-`IgnoreSymbols`
131
127
132
-
As there is no IgnoreSymbols equivalent in NSStringCompareOptions all `CompareOptions` combinations that include `IgnoreSymbols` throw `PlatformNotSupportedException`
128
+
Supported by filtering ignorable symbols on the managed side prior to comparison using native API.
0 commit comments