Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 86777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:17:57+00:00 2026-05-10T22:17:57+00:00

I need to compare 2 strings in C# and treat accented letters the same

  • 0

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.Equals(s2, StringComparison.InvariantCultureIgnoreCase); s1.Equals(s2, StringComparison.OrdinalIgnoreCase); 

These 2 strings need to be the same (as far as my application is concerned), but both of these statements evaluate to false. Is there a way in C# to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:17:58+00:00Added an answer on May 10, 2026 at 10:17 pm

    FWIW, knightfor’s answer below (as of this writing) should be the accepted answer.

    Here’s a function that strips diacritics from a string:

    static string RemoveDiacritics(string text) {   string formD = text.Normalize(NormalizationForm.FormD);   StringBuilder sb = new StringBuilder();    foreach (char ch in formD)   {     UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(ch);     if (uc != UnicodeCategory.NonSpacingMark)     {       sb.Append(ch);     }   }    return sb.ToString().Normalize(NormalizationForm.FormC); } 

    More details on MichKap’s blog (RIP…).

    The principle is that is it turns ‘é’ into 2 successive chars ‘e’, acute. It then iterates through the chars and skips the diacritics.

    "héllo" becomes "he<acute>llo", which in turn becomes "hello".

    Debug.Assert("hello"==RemoveDiacritics("héllo")); 

    Note: Here’s a more compact .NET4+ friendly version of the same function:

    static string RemoveDiacritics(string text) {   return string.Concat(        text.Normalize(NormalizationForm.FormD)       .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch)!=                                     UnicodeCategory.NonSpacingMark)     ).Normalize(NormalizationForm.FormC); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my code I need to compare string letters but my problem is that
I need to compare hash values of two strings. I use string template for
in php i need to compare 2 strings. str1=this is a string str2= this
I get two strings formated like (Brazilian Format): DD/MM/YYYY, I need to compare both.
I'm developping a web app and I need encrypt strings in javascript to compare
I need to compare the last string of a url with the id of
I have an if statement, and I need to compare a single string with
I need to compare a key object from a div to a string. I
I'm using two string vectors to store two text files. I need to compare
I need to compare two strings, containing HTML text. The test should return true

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.