[英]How to remove acute accents from string in java?
I know about this我知道这件事
public static String stripAccents(String s) {
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s;
}
but it works not the way I want.但它的工作方式不是我想要的。 It changes the sense of text
它改变了文本的意义
stripAccents("йод,ëлка,wäre") //иод,елка,ware
I want to delete only acute accents我只想删除重音符号
stripAccents("café") //cafe
I know about this我知道这件事
public static String stripAccents(String s) {
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s;
}
but it works not the way I want.但它的工作方式不是我想要的。 It changes the sense of text
它改变了文本的意义
stripAccents("йод,ëлка,wäre") //иод,елка,ware
I want to delete only acute accents我只想删除重音符号
stripAccents("café") //cafe
I know about this我知道这件事
public static String stripAccents(String s) {
s = Normalizer.normalize(s, Normalizer.Form.NFD);
s = s.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
return s;
}
but it works not the way I want.但它的工作方式不是我想要的。 It changes the sense of text
它改变了文本的意义
stripAccents("йод,ëлка,wäre") //иод,елка,ware
I want to delete only acute accents我只想删除重音符号
stripAccents("café") //cafe
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.