I need to compare 2 strings in C# and treat accented letters the same as non-accented letters. For example:
string s1 = \"hello\";
string s2 = \"héllo\";
s1
If you don't need to convert the string and you just want to check for equality you can use
string s1 = "hello";
string s2 = "héllo";
if (String.Compare(s1, s2, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0)
{
// both strings are equal
}
or if you want the comparison to be case insensitive as well
string s1 = "HEllO";
string s2 = "héLLo";
if (String.Compare(s1, s2, CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase) == 0)
{
// both strings are equal
}