Created
March 27, 2016 18:41
-
-
Save neelsmith/bcddfcff482112fd5b29 to your computer and use it in GitHub Desktop.
Read Unicode code points in a string, convert to strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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