Skip to content

Instantly share code, notes, and snippets.

@neelsmith
Created March 27, 2016 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neelsmith/bcddfcff482112fd5b29 to your computer and use it in GitHub Desktop.
Save neelsmith/bcddfcff482112fd5b29 to your computer and use it in GitHub Desktop.
Read Unicode code points in a string, convert to strings
// Use a UCharacterIterator to loop through code points in a Unicode string,
// and convert each code point to a String.
@Grab('com.ibm.icu:icu4j:3.4.4')
import com.ibm.icu.text.UCharacterIterator
String s = "μῆνιν"
def iter = UCharacterIterator.getInstance (s)
def cp
while(( cp=iter.nextCodePoint())!= UCharacterIterator.DONE){
println new String(Character.toChars(cp))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment