How do i replace accents (german) in .NET

前端 未结 5 2158
有刺的猬
有刺的猬 2020-12-03 17:36

I need to replace accents in the string to their english equivalents

for example

ä = ae

ö = oe

Ö = Oe

ü = ue

I know to strip

5条回答
  •  执念已碎
    2020-12-03 18:33

    How about using string.Replace:

    string germanText = "Mötörhead";
    string replaced = germanText.Replace("ö", "oe");
    

    (okay, not a real German word, but I couldn't resist)

    You can chain calls to Replace like this

    someText.Replace("ö", "oe").Replace("ä", "ae").Replace("ö", "oe")...
    

提交回复
热议问题