如何替换字符串中的umlauts?

6
有没有好的库可以将umlauts和特殊字符转换为它们的“平面”表示?例如:
Ä -> AE
Ü -> UE
ß -> ss

你有什么建议吗?

你是否专门处理德语umlauts? - Satheesh Cheveri
目前是的。但以后可能也会有其他语言。 - membersound
1
嗯,应该是Ä -> Ae,Ö -> Oe,... 从未见过大写的e版本。另外,有什么阻止你使用String.replace函数吗?像这样 String replaced = "Ärmel Über Öffnung".replace("Ä", "Ae").replace("Ö", "Oe").replace("Ü", "Ue"); - Matthias
1
当整个单词被大写时(如在标题或强调中),您将使用全大写的AE。 - DThought
请参见Rename ä, ö, ü to ae, oe, ue - Martin Schröder
1个回答

0

使用StringUtils,这不是著名的Apache库。它可以解决你的问题。

replaceUmlauts

public static java.lang.String replaceUmlauts(java.lang.String string)

Replaces all umlauts in a string.
Umlaut  Replacement
ä   ae
ö   oe
ü   ue
ß   ss

Parameters:
    string - String, where the umlauts has to be replaced 
Returns:
    String without umlauts

5
我不会相信那个图书馆可以解决除了家庭作业之外的任何问题。 - Marko Topolnik
2
这甚至不是一个库,而是一个包含这样一个类的应用程序。没有人说其他人可以将该类用于其他程序。 - Holger

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接