本文整理汇总了Java中com.ibm.icu.lang.UScript.getScript方法的典型用法代码示例。如果您正苦于以下问题:Java UScript.getScript方法的具体用法?Java UScript.getScript怎么用?Java UScript.getScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UScript
的用法示例。
在下文中一共展示了UScript.getScript方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getScript
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
/**
* fast version of UScript.getScript(). Basic Latin is an array lookup
*/
private int getScript(int codepoint) {
if (0 <= codepoint && codepoint < basicLatin.length) {
return basicLatin[codepoint];
} else {
int script = UScript.getScript(codepoint);
if (combineCJ) {
if (script == UScript.HAN || script == UScript.HIRAGANA || script == UScript.KATAKANA) {
return UScript.JAPANESE;
} else if (codepoint >= 0xFF10 && codepoint <= 0xFF19) {
// when using CJK dictionary breaking, don't let full width numbers go to it, otherwise
// they are treated as punctuation. we currently have no cleaner way to fix this!
return UScript.LATIN;
} else {
return script;
}
} else {
return script;
}
}
}
示例2: getScript
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
/** fast version of UScript.getScript(). Basic Latin is an array lookup */
private int getScript(int codepoint) {
if (0 <= codepoint && codepoint < basicLatin.length) {
return basicLatin[codepoint];
} else {
int script = UScript.getScript(codepoint);
if (combineCJ) {
if (script == UScript.HAN || script == UScript.HIRAGANA || script == UScript.KATAKANA) {
return UScript.JAPANESE;
} else if (codepoint >= 0xFF10 && codepoint <= 0xFF19) {
// when using CJK dictionary breaking, don't let full width numbers go to it, otherwise
// they are treated as punctuation. we currently have no cleaner way to fix this!
return UScript.LATIN;
} else {
return script;
}
} else {
return script;
}
}
}
示例3: buildScores
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
private static void buildScores(String text, Map<Integer, AtomicInteger> scores) {
try {
char[] chararray = text.toCharArray();
for (int i = 0; i < text.length(); i++) {
int code = UScript.getScript(UCharacter.codePointAt(chararray, i));
increaseScoreFor(scores, code);
}
} catch (Exception ignored) {
}
}
示例4: getScript
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
/** fast version of UScript.getScript(). Basic Latin is an array lookup */
private static int getScript(int codepoint) {
if (0 <= codepoint && codepoint < basicLatin.length)
return basicLatin[codepoint];
else
return UScript.getScript(codepoint);
}
示例5: next
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
/**
* Returns TRUE if there are any more runs. TRUE is always
* returned at least once. Upon return, the caller should
* examine scriptCode, start, and limit.
*/
public boolean next() {
int ch;
int s;
scriptCode = UScript.INVALID_CODE; // don't know script yet
start = limit;
// Are we done?
if (start == textLimit) {
return false;
}
// Move start back to include adjacent COMMON or INHERITED
// characters
while (start > textStart) {
ch = text.char32At(start - 1); // look back
s = UScript.getScript(ch);
if (s == UScript.COMMON || s == UScript.INHERITED) {
--start;
} else {
break;
}
}
// Move limit ahead to include COMMON, INHERITED, and characters
// of the current script.
while (limit < textLimit) {
ch = text.char32At(limit); // look ahead
s = UScript.getScript(ch);
if (s != UScript.COMMON && s != UScript.INHERITED) {
if (scriptCode == UScript.INVALID_CODE) {
scriptCode = s;
} else if (s != scriptCode) {
break;
}
}
++limit;
}
// Return TRUE even if the entire text is COMMON / INHERITED, in
// which case scriptCode will be UScript.INVALID_CODE.
return true;
}
示例6: getValue
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
@Override
int getValue(int c) {
return UScript.getScript(c);
}
示例7: includesCharacter
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
public boolean includesCharacter(int codePoint)
{
if (includedScripts == null && excludedScripts == null)
{
return true;
}
int codeScript = UScript.getScript(codePoint);
if (codeScript == UScript.UNKNOWN)
{
//include by default
return true;
}
if (codeScript == UScript.COMMON)
{
//COMMON is included unless explicitly excluded
return !excludedCommon;
}
if (codeScript == UScript.INHERITED)
{
//INHERITED is included unless explicitly excluded
return !excludedInherited;
}
if (includedScripts != null && includedScripts.contains(codeScript))
{
//the codepoint script is explicitly included
return true;
}
if (excludedScripts != null && excludedScripts.contains(codeScript))
{
//the codepoint script is explicitly excluded
return false;
}
if (includedScripts == null)
{
//not excluded
return true;
}
for (Integer script : includedScripts)
{
if (UScript.hasScript(codePoint, script))
{
//included as a secondary/extension script
return true;
}
}
//not included
return false;
}