Created
February 11, 2015 13:54
-
-
Save jprante/3ef160e916c452df5e79 to your computer and use it in GitHub Desktop.
Detect latin/greek characters
This file contains hidden or 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
def file = new File('names.txt') | |
file.eachLine { line -> | |
if (line.length() > 16) { | |
line = line.substring(16) | |
line.tokenize('$').each { word -> | |
word = word.substring(1) | |
print word | |
def latin = false | |
def greek = false | |
word.replaceAll("\\p{C}","").replaceAll("\\p{Space}","").replaceAll("\\p{Punct}","").toCharArray().each { c -> | |
def i = c as int | |
if (i > 32 && i < 256) { | |
latin = true | |
} | |
else if (i > 0x0370 && i < 0x0400) { | |
greek = true | |
} | |
else { | |
print " not latin/greek char:" << Integer.toHexString(i) | |
} | |
} | |
if (latin) { | |
print " latin" | |
} | |
if (greek) { | |
print " greek" | |
} | |
print "\n" | |
} | |
print "\n" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment