MonoTouch String Comparison

I have an application that lists many languages. In the application, I compare the names of languages.

When I compare language names without accents, it works, and the comparison is true.

When I compare languages ​​with accents, they don’t think they are equal.

In this case, they are NOT equal (but should be).

Language = "Español";
MonoTouch.Foundation.NSString s = new MonoTouch.Foundation.NSString(Language);
MonoTouch.Foundation.NSString l = new MonoTouch.Foundation.NSString ("Español");

In this example, they are equal (do not notice the accents).

Language = "Deutsch";
MonoTouch.Foundation.NSString s = new MonoTouch.Foundation.NSString(Language);
MonoTouch.Foundation.NSString l = new MonoTouch.Foundation.NSString ("Deutsch");

I tried to combine the comparison with the results to no avail.

Did I miss something fundamental here?

I am using MonoTouch 1.4.4

+3
source share
1 answer

the following matches, as you need to ignore accents:

var Language = "Español" ;
MonoTouch.Foundation.NSString s = new MonoTouch.Foundation.NSString(Language);
MonoTouch.Foundation.NSString l = new MonoTouch.Foundation.NSString ("Español");

int result = String.Compare(s,l, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace);
+2
source

Source: https://habr.com/ru/post/1730944/


All Articles