I want to write a F# or C# function that removes Spanish accents from a string like so:
in: "a stríng withóut áccents"
->
out: "a string without accents"
I know how to achieve this in Python 3:
trans_table = str.maketrans( "áéíóúñÁÉÍÓÚÑàèìòùäëïöü", "aeiounAEIOUNaeiouaeiuo" )
# trans_table now contains a dictionary: { "á" : "a", "é" : "e", ... }
"A stríng withóut áccents".translate( trans_table )
# result is: A string without accents
Mimicking this solution would be rather straight forward if the characters to be translated where regular ascii characters (in the 0-127 range). However, because of the way .NET encodes strings it doesn't seem straight forward to do it for actual unicode characters out of this range...
I would like a solution that does not imply doing a regex-replace for each one of the many accented characters but that hopefully loops over the string only once...
Any ideas?