i'm paging countries in an alfabet, so countries starting A-D, E-H etc. But i also want to list åbrohw at the a, and ëpollewop at the e. I tried string.startswith providing a stringcompare option, but it doesn't work...
i'm running under the sv-SE culture code, if that matters...
Michel
See How do I remove diacritics (accents) from a string in .NET? for the solution to create a version without the diacritics, which you can use for the comparisons (while still displaying the version with the diacritics).
Oh yes, the culture matters. If you run the following:
List<string> letters = new List<string>() { "Å", "B", "A" };
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("sv-SE");
letters.Sort();
Console.WriteLine("sv-SE:")
letters.ForEach(s => Console.WriteLine(s));
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");
letters.Sort();
Console.WriteLine("en-GB:")
letters.ForEach(s => Console.WriteLine(s));
...you get the following output:
sv-SE:
A
B
Å
en-GB:
A
Å
B
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With