1

We know a tolower function will turn all A to a

How to turn all à to a.

The purpose is I am creating ids for databases and id need to be unique. Sometimes the same stores are written as à in one place and as a on other places. This will create duplicate id problem.

So I need a function that will turn all à and all of it's variation into a. The same way ě should become e.

Basically I would use utf8_unicode collation on my databases. Letters that count as the same letter under that collation should map to the same character under this function.

I need to make sure that all other east asian characers are not affected in anyway.

How can I do so?

user4951
  • 32,206
  • 53
  • 172
  • 282
  • [How do I remove diacritics (accents) from a string in .NET?](http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net) – Tim Schmelter Mar 20 '12 at 07:53

1 Answers1

-1
static string RemoveDiacritics(string stIn) 
        { 
            string stFormD = stIn.Normalize(NormalizationForm.FormD); 
            StringBuilder sb = new StringBuilder(); 
            for (int ich = 0; ich < stFormD.Length; ich++) 
            { 
                UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[ich]); 
                if (uc != UnicodeCategory.NonSpacingMark) 
                { 
                    sb.Append(stFormD[ich]); 
                } 
            } 
            return (sb.ToString().Normalize(NormalizationForm.FormC));
        }
Kishore Kumar
  • 12,675
  • 27
  • 97
  • 154
  • oh there is no built in function isn't it? – user4951 Mar 20 '12 at 09:04
  • 2
    You should at least reference your sources... http://blogs.msdn.com/b/michkap/archive/2007/05/14/2629747.aspx or http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net – Gabriele Petrioli Mar 20 '12 at 09:20