|
|
@ -138,27 +138,38 @@ public class TextHelper {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
int codepoint;
|
|
|
|
int codepoint;
|
|
|
|
Character.UnicodeScript us;
|
|
|
|
Character.UnicodeScript script;
|
|
|
|
Character.UnicodeScript script = null;
|
|
|
|
List<Character.UnicodeScript> scripts = new ArrayList<>();
|
|
|
|
for (int i = 0; i < s.length(); ) {
|
|
|
|
for (int i = 0; i < s.length(); ) {
|
|
|
|
codepoint = s.codePointAt(i);
|
|
|
|
codepoint = s.codePointAt(i);
|
|
|
|
i += Character.charCount(codepoint);
|
|
|
|
i += Character.charCount(codepoint);
|
|
|
|
us = Character.UnicodeScript.of(codepoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Character.isSpaceChar(codepoint)) {
|
|
|
|
if (Character.isSpaceChar(codepoint))
|
|
|
|
script = null;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Character.UnicodeScript.COMMON.equals(us))
|
|
|
|
script = Character.UnicodeScript.of(codepoint);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (Character.UnicodeScript.COMMON.equals(script))
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
if (script == null)
|
|
|
|
if (!scripts.contains(script))
|
|
|
|
script = us;
|
|
|
|
scripts.add(script);
|
|
|
|
else if (!us.equals(script))
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
if (scripts.size() <= 1)
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
scripts.remove(Character.UnicodeScript.HAN); // Chinese/Japanese
|
|
|
|
|
|
|
|
scripts.remove(Character.UnicodeScript.HIRAGANA); // Japanese
|
|
|
|
|
|
|
|
scripts.remove(Character.UnicodeScript.KATAKANA); // Japanese
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scripts.size() == 0)
|
|
|
|
|
|
|
|
return true; // All Chinese/Japanese
|
|
|
|
|
|
|
|
if (scripts.size() > 1)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Chinese/Japanese + Latin
|
|
|
|
|
|
|
|
return Character.UnicodeScript.LATIN.equals(scripts.get(0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static String getNonLatinCodepoints(String text) {
|
|
|
|
static String getNonLatinCodepoints(String text) {
|
|
|
|