I have a method that I am using to remove accents from certain characters. The problem is the massive slew of characters I am expected to work with. I have to, basically, remove accents from all Latin characters that fit within the 26 English Latin characters. (A through Z.) Performance is a very large requirement. It has to be lightning fast, as I have to run this on every character within a string, and process many large strings at a time.Currently, I use a gigantic switch statement to detect what character it is, and return the appropriate A through Z naked character, while preserving case.As of now, my switch looks something like the following:switch (input){    case '': // 0192    case '': // 0193    case '': // 0194    case '': // 0195    case '': // 0196    case '': // 0197    case '': // 0256    case '': // 0258    case '': // 0260        return 'A';    case '': // 0199    case '': // 0262    case '': // 0264    case '': // 0266    case '': // 0268        return 'C';    case '': // 0270    case '': // 0272        return 'D';    // Other upper case characters    case '': // 0224    case '': // 0225    case '': // 0226    case '': // 0227    case '': // 0228    case '': // 0229    case '': // 0257    case '': // 0259    case '': // 0261        return 'a';    case '': // 0231    case '': // 0263    case '': // 0265    case '': // 0267    case '': // 0269        return 'c';    case '': // 0271    case '': // 0273        return 'D';    // Other lower case characters    default:        return input;}As you can probably imagine, this method is over 200 lines, and this is the only thing it does.private char RemoveAccent(char input){    switch (input)    {        // You saw all the case statements    }}Literally, that is it. My questions come down to the following, and this is more of a question of performance/better ways of handling the situation.I know I can take a Regex and do the same thing very easily. It's what I used in the beginning as a shortcut. The problem, is that the regex is phenomenally slow. Essentially, what I was doing is looping over the 26 alphas, and then using the regex [ALPHACHARACTER], and replacing it with ALPHACHARACTER.This method, however, was horrendous in performance. Over a set of input x, with data logic y, it was a whopping 1500ms.Now, when I exclude this method from the logic, it performed at about 110ms. This is with the same input x and logic y, mind you. The only difference is that this method had a body of return input;.So, I went to the switch method, which is very high in performance, and very low in maintainability. (The Calculate Code Metrics in Visual Studio puts it at a 41 for this method.) This one performed at 120ms with the exact same remaining logic 'y' and input 'x' as the Regex option. This allows me to exclude all other logic as being the issue.The only other option I can think of, is to use an if statement on character ranges to at least make it more maintainable. The question on it is performance.if ((input >= '' && input <= '') || (input >= '' && input <= '' && input % 2 == 0))    return 'A';else if ((input == '') || (input >= '' && input <= '' && input % 2 == 0))    return 'C';else if (input >= '' && input <= '' && input % 2 == 0)    return 'D';// Other upper case characterselse if ((input >= '' && input <= '') || (input >= '' && input <= '' && input % 2 == 1))    return 'A';else if ((input == '') || (input >= '' && input <= '' && input % 2 == 1))    return 'C';else if (input >= '' && input <= '' && input % 2 == 1)    return 'D';// Other lower case charactersreturn input;Also, this is not all of the inputs. The 200 lines I mentioned earlier doesn't even cover a quarter of the characters I have to support. The thing is, I find the switch more readable, personally.My questions are:Is there a significantly more readable way, to write this, without significantly losing performance?Is my switch statement the way to go if I favour performance over maintainability?Should I stick with it regardless of what metrics Visual Studio might mention if it's more readable/understandable to me, and already has acceptable performance?Is there something already in .NET to do what I am that might perform faster?The only reason I ask these things, is that I feel like I'm doing something wrong, like I'm missing something in the way I approach this.Personally, I think that since I find it readable, and it's already fast enough, there's no point to change it. The only problem is that I still have a lot of options to add to it, so it will only grow in size. The management of it could get a bit out of hand.
Removing accents from certain characters
c#;performance;strings;.net;unicode
This appears to be a duplicate of this question. The link suggests using .NET's String.Normalize. If it's too slow, you could simply create an associative array (e.g., a Dictionary that maps char->char) for constant-time lookup. This is going to be large, too, but I would think it's probably easier to maintain.