本文整理汇总了Java中com.ibm.icu.lang.UScript.getCode方法的典型用法代码示例。如果您正苦于以下问题:Java UScript.getCode方法的具体用法?Java UScript.getCode怎么用?Java UScript.getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.lang.UScript
的用法示例。
在下文中一共展示了UScript.getCode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scriptNameToCode
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
/**
* Return the script code for a given name, or
* UScript.INVALID_CODE if not found.
*/
private static int scriptNameToCode(String name) {
try{
int[] codes = UScript.getCode(name);
return codes != null ? codes[0] : UScript.INVALID_CODE;
}catch( MissingResourceException e){
///CLOVER:OFF
return UScript.INVALID_CODE;
///CLOVER:ON
}
}
示例2: addScriptChars
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
private void addScriptChars(ULocale locale, UnicodeSet allowedChars) {
int scripts[] = UScript.getCode(locale);
if (scripts != null) {
UnicodeSet tmpSet = new UnicodeSet();
for (int i = 0; i < scripts.length; i++) {
tmpSet.applyIntPropertyValue(UProperty.SCRIPT, scripts[i]);
allowedChars.addAll(tmpSet);
}
}
// else it's an unknown script.
// Maybe they asked for the script of "zxx", which refers to no linguistic content.
// Maybe they asked for the script of a newer locale that we don't know in the older version of ICU.
}
示例3: Spec
import com.ibm.icu.lang.UScript; //导入方法依赖的package包/类
public Spec(String theSpec) {
top = theSpec;
spec = null;
scriptName = null;
try{
// Canonicalize script name. If top is a script name then
// script != UScript.INVALID_CODE.
int script = UScript.getCodeFromName(top);
// Canonicalize script name -or- do locale->script mapping
int[] s = UScript.getCode(top);
if (s != null) {
scriptName = UScript.getName(s[0]);
// If the script name is the same as top then it's redundant
if (scriptName.equalsIgnoreCase(top)) {
scriptName = null;
}
}
isSpecLocale = false;
res = null;
// If 'top' is not a script name, try a locale lookup
if (script == UScript.INVALID_CODE) {
Locale toploc = LocaleUtility.getLocaleFromName(top);
res = (ICUResourceBundle)UResourceBundle.getBundleInstance(ICUData.ICU_TRANSLIT_BASE_NAME,toploc);
// Make sure we got the bundle we wanted; otherwise, don't use it
if (res!=null && LocaleUtility.isFallbackOf(res.getULocale().toString(), top)) {
isSpecLocale = true;
}
}
}catch(MissingResourceException e){
///CLOVER:OFF
// The constructor is called from multiple private methods
// that protects an invalid scriptName
scriptName = null;
///CLOVER:ON
}
// assert(spec != top);
reset();
}