Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created May 9, 2012 16:11
Show Gist options
  • Save kiy0taka/2646039 to your computer and use it in GitHub Desktop.
Save kiy0taka/2646039 to your computer and use it in GitHub Desktop.
@Grab('com.ibm.icu:icu4j:4.8.1.1')
import com.ibm.icu.text.Transliterator
class StringCategory {
static hankaku = Transliterator.getInstance('Fullwidth-Halfwidth').&transliterate
static String div(String self, int divisor) {
divisor == 2 ? hankaku(self) : self
}
}
use (StringCategory) {
assert '這いよれ! ニャル子さん 4' / 2 == '這いよれ! ニャル子さん 4'
assert 'ABC' / 2 == 'ABC'
assert 'あ い う え お' / 2 == 'あ い う え お'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment