Replace éàçè… with equivalent “eace” In GWT

喜夏-厌秋 提交于 2019-12-04 01:58:05

问题


I tried s=Normalizer.normalize(s, Normalizer.Form.NFD).replaceAll("[^\\p{ASCII}]", ""); But it seems that GWT API doesn't provide such fonction.

I tried also :

s=s.replace("é",e);

But it doesn't work either

The scenario is I'am trying to générate token from the clicked Widget's text for the history management


回答1:


You can take ASCII folding filter from Lucene and add to your project. You can just take foldToASCII() method from ASCIIFoldingFilter (the method does not have any dependencies). There is also a patch in Jira that has a full class for that without any dependencies - see here. It should be compiled by GWT without any problems. License should be also OK, since it is Apache License, but don't quote me on it - you should ask a real lawyer.




回答2:


@okrasz, the foldToASCII() worked but I found a shorter one Transform a String to URL standard String in Java



来源:https://stackoverflow.com/questions/7500673/replace-%c3%a9%c3%a0%c3%a7%c3%a8-with-equivalent-eace-in-gwt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!