I have an ASP.Net Core Project with an MVC configuration. I use ASP.Net Core Version 5.0 My native language is german and therefore our database is also filled with german words, for example the word "fußball" (which means football or soccer, depending on where you are from).
As you can see, this word has an ß. In german, this "ß" is basically equivalent to "ss". Therefore if I have the string "fußball" I want to be able to find it if someone searches for "fussball" also.
I understand that ASP.Net Core has good localization and globalization options, I just can't seem to figure this one out.
Consider the following code:
var currCulture = CultureInfo.CurrentCulture.Name; // = "de-AT"
var str1 = "fußball";
str1.StartsWith("fuss"); //returns false
str1.StartsWith("fuss", StringComparison.InvariantCulture); //returns false
String.Equals("ß", "ss", StringComparison.InvariantCulture); //returns false
since I use my Windows-PC in an english language and I read in another Stackoverflow question that the CultureInfo is dependent on the operating system, I decided to insert the following into my Startup.cs
-File, as suggested in this Stackoverflow question
var cultureInfo = new CultureInfo("de-AT"); //de-AT for Austria, i tried with de-DE too for germany, but the result was the same
cultureInfo.NumberFormat.CurrencySymbol = "€";
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
unfortunately, with my current setup, it always tells me that "ß" and "ss" are not the same when comparing them in strings. The same goes for "ä" and "ae", but I need these to be found in the same way. Regardless of if the input is "ä"/"ae" or "ß"/"ss".
Any ideas what I've been doing wrong are greatly appreciated, I just can't seem to get this to work.
Thank you in advance & best regards!