是否有一个函数可以为我提供字母的任何“变体”(如“à”、“ä”等)基本字母(“a”)?当然,我知道如何使用 switch 创建一个函数,但我必须注意每一个变化。
最佳答案
您可以使用Apache Common String Utils
例如:
String accentLetter1 = "ä";
String accentLetter2 = "à";
System.out.println(org.apache.commons.lang3.StringUtils.stripAccents(accentLetter1));
System.out.println(org.apache.commons.lang3.StringUtils.stripAccents(accentLetter2));
显示
a
a
Artifact 可在 Maven Repository 中找到
关于java - 在java中将字母的变体转换为基本字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32639086/