views:

101

answers:

1

I have an app which lists many languages. In the app I compare language names.

When I compare language names with no accents it works and the compare is true.

When I compare languages with accents, it doesn'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 (notice no accents).

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

I have tried cultureinvariate compares to no avail.

Am I missing something fundamental here?

I am using MonoTouch 1.4.4

+1  A: 

Hi there,

the following matches as you require ignoring 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);

Hope this helps.

Alex

Blounty