替换德语字符(变音,重音)与英文对应
Replace German characters (umlauts, accents) with english equivalents
我需要删除的文字处理的各个领域德国的任何特殊字符转换成另一种系统,它惯于接受它们是有效的。
I need to remove any german specific characters from various fields of text for processing into another system which wont accept them as valid.
所以我知道的字符是:
SS 一个 ö ü 一个 Ö U
ß ä ö ü Ä Ö Ü
目前,我有一点取而代之的手动方式:
At the moment I have a bit of a manual way of replacing them:
myGermanString.Replace("ä","a").Replace("ö","o").Replace("ü","u").....
不过,我希望有这样做的一个简单/更有效的方式。因为我将在上千个运行的字符串,其中99%将不包含这些字符的做这件事。
But I was hoping there was a simpler / more efficient way of doing it. Since I'll be doing it on thousands of strings per run, 99% of which will not contain these chars.
也许涉及某种形式的CultureInfo的方法?
Maybe a method involving some sort of CultureInfo?
(例如,根据质谱,下面将返回字符串相等
(for example, according to MS, the following returns the strings are equal
String.Compare("Straße", "Strasse", StringComparison.CurrentCulture);
所以必须有某种转换表中已经存在的?)
so there must be some sort of conversion table already existing?)
@如果你要删除的变音符号巴里的回答是不错的。
@Barry's answer is good if you want to remove the diacritics.
不过,在德国它通常以取代U => UE,O => OE等。
But in German it's usual to replace ü => ue, ö => oe etc.
这里有一个链接到一个类似的问题。