* support icu4j unicode transliteration in order to allow unicode-to-ascii conversion in format engine

This commit is contained in:
Reinhard Pointner 2012-02-09 09:44:00 +00:00
parent 1dbe3b81c7
commit c766513acf
3 changed files with 10 additions and 2 deletions

View File

@ -125,7 +125,7 @@
</zipfileset> </zipfileset>
<zipfileset src="${dir.lib}/icu4j.jar"> <zipfileset src="${dir.lib}/icu4j.jar">
<include name="com/ibm/icu/text/**" /> <include name="com/ibm/icu/**" />
</zipfileset> </zipfileset>
<zipfileset src="${dir.lib}/sublight-ws.jar"> <zipfileset src="${dir.lib}/sublight-ws.jar">

Binary file not shown.

View File

@ -117,3 +117,11 @@ String.metaClass.replacePart = { replacement = "" ->
// no pattern matches, nothing to replace // no pattern matches, nothing to replace
return delegate; return delegate;
} }
/**
* Convert Unicode to ASCII as best as possible. This method will translate umlauts, accents, etc to corresponding ASCII characters.
*
* e.g. "Österreich" -> "Osterreich"
* "カタカナ" -> "katakana"
*/
String.metaClass.ascii = { com.ibm.icu.text.Transliterator.getInstance("Any-Latin;Latin-ASCII").transform(delegate).replaceAll("[^\\p{ASCII}]", "?") }