本文整理匯總了Java中java.lang.Character.UnicodeBlock.TAMIL屬性的典型用法代碼示例。如果您正苦於以下問題:Java UnicodeBlock.TAMIL屬性的具體用法?Java UnicodeBlock.TAMIL怎麽用?Java UnicodeBlock.TAMIL使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類java.lang.Character.UnicodeBlock
的用法示例。
在下文中一共展示了UnicodeBlock.TAMIL屬性的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: recognizeLanguage
public static int recognizeLanguage(String text) {
int kanCount = 0;
int tamCount = 0;
int digitCount = 0;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
UnicodeBlock ub = UnicodeBlock.of(c);
if (ub == UnicodeBlock.KANNADA) {
kanCount++;
} else if (ub == UnicodeBlock.TAMIL) {
tamCount++;
} else if (Character.isDigit(c)) {
digitCount++;
}
}
if (kanCount == 0 && tamCount == 0) {
if (digitCount > 0) {
return PREVIOUS_LANGUAGE;
}
return LANGUAGE_UNKNOWN;
}
if (tamCount > kanCount) {
PREVIOUS_LANGUAGE = LANGUAGE_TAMIL;
return LANGUAGE_TAMIL;
} else {
PREVIOUS_LANGUAGE = LANGUAGE_KANNADA;
return LANGUAGE_KANNADA;
}
}
示例2: classify
/**
* Given a unicode block object, return corresponding language constant.
* If the block is not recognized, returns zero. Note that as there
* is no separate ARABIC block in Character, this case must
* be specially handled by the caller; EASTERN_ARABIC is preferred when
* both are specified.
* @param b the unicode block to classify
* @return the language constant, or zero if not recognized
*/
private int classify(UnicodeBlock b)
{
if (b == null)
return 0;
// ARABIC is handled by the caller; from testing we know
// that EASTERN_ARABIC takes precedence.
if (b == UnicodeBlock.ARABIC)
return EASTERN_ARABIC;
if (b == UnicodeBlock.BENGALI)
return BENGALI;
if (b == UnicodeBlock.DEVANAGARI)
return DEVANAGARI;
if (b == UnicodeBlock.ETHIOPIC)
return ETHIOPIC;
if (b == UnicodeBlock.BASIC_LATIN
|| b == UnicodeBlock.LATIN_1_SUPPLEMENT
|| b == UnicodeBlock.LATIN_EXTENDED_A
|| b == UnicodeBlock.LATIN_EXTENDED_ADDITIONAL
|| b == UnicodeBlock.LATIN_EXTENDED_B)
return EUROPEAN;
if (b == UnicodeBlock.GUJARATI)
return GUJARATI;
if (b == UnicodeBlock.GURMUKHI)
return GURMUKHI;
if (b == UnicodeBlock.KANNADA)
return KANNADA;
if (b == UnicodeBlock.KHMER)
return KHMER;
if (b == UnicodeBlock.LAO)
return LAO;
if (b == UnicodeBlock.MALAYALAM)
return MALAYALAM;
if (b == UnicodeBlock.MONGOLIAN)
return MONGOLIAN;
if (b == UnicodeBlock.MYANMAR)
return MYANMAR;
if (b == UnicodeBlock.ORIYA)
return ORIYA;
if (b == UnicodeBlock.TAMIL)
return TAMIL;
if (b == UnicodeBlock.TELUGU)
return TELUGU;
if (b == UnicodeBlock.THAI)
return THAI;
if (b == UnicodeBlock.TIBETAN)
return TIBETAN;
return 0;
}