从字符串中删除重音 [英] Remove accents from String
本文介绍了从字符串中删除重音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在Android中的(据我所知)没有java.text.Normalizer,从字符串中删除任何口音。例如香水变为淡。
Is there any way in Android that (to my knowledge) doesn't have java.text.Normalizer, to remove any accent from a String. E.g "éàù" becomes "eau".
我想避免解析字符串来检查每个字符,如果可能的!
I'd like to avoid parsing the String to check each character if possible!
推荐答案
java.text.Normalizer
是那里的Android(在最新的版本是这样)。你可以使用它。
java.text.Normalizer
is there in Android (on latest versions anyway). You can use it.
修改作为参考,在这里是如何使用正规化
:
EDIT For reference, here is how to use Normalizer
:
string = Normalizer.normalize(string, Normalizer.Form.NFD);
string = string.replaceAll("[^\\p{ASCII}]", "");
(来自链路粘贴在下面评论)
(pasted from the link in comments below)
这篇关于从字符串中删除重音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文