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

Binary file not shown.

View File

@ -117,3 +117,11 @@ String.metaClass.replacePart = { replacement = "" ->
// no pattern matches, nothing to replace
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}]", "?") }