I need to compare strings for a search mechanism on a web site. I use C#. I tried two ways:
consultants.Where(x =>
x.Description.ToLower().Contains(v
Thanks to all who offered suggestions, but unfortunately they seem to be irrelevant. As it turns out Contains() has no problem with non-English characters at all. The problem was that the database field in question had html encoded text, so I needed to use HtmlDecode to compare the strings in the controller:
if (vm.Description != "")
{
//HttpUtility.HtmlDecode needed because text in Description field is HtmlEncoded!
consultants = consultants.Where(x => HttpUtility.HtmlDecode(x.Description).ContainsCaseInsensitive(vm.Description)).ToList();
}
I discovered this because the Contains() code worked fine when searching another field with non-English characters.