当前位置: 首页>>代码示例>>Java>>正文


Java UCharacter类代码示例

本文整理汇总了Java中com.ibm.icu.lang.UCharacter的典型用法代码示例。如果您正苦于以下问题:Java UCharacter类的具体用法?Java UCharacter怎么用?Java UCharacter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UCharacter类属于com.ibm.icu.lang包,在下文中一共展示了UCharacter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parseReference

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
public String parseReference(String text, ParsePosition pos, int limit) {
    int start = pos.getIndex();
    int i = start;
    String result = "";
    while (i < limit) {
        int c = UTF16.charAt(text, i);
        if ((i == start && !UCharacter.isUnicodeIdentifierStart(c))
                || !UCharacter.isUnicodeIdentifierPart(c)) {
            break;
        }
        i += UTF16.getCharCount(c);
    }
    if (i == start) { // No valid name chars
        return result; // Indicate failure with empty string
    }
    pos.setIndex(i);
    result = text.substring(start, i);
    return result;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:20,代码来源:RBBISymbolTable.java

示例2: copyAsSuperscript

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
private static void copyAsSuperscript(
        AttributedCharacterIterator iterator, int start, int limit, StringBuilder result) {
    int oldIndex = iterator.getIndex();
    iterator.setIndex(start);
    while (iterator.getIndex() < limit) {
        int aChar = char32AtAndAdvance(iterator);
        int digit = UCharacter.digit(aChar);
        if (digit < 0) {
            throw new IllegalArgumentException();
        }
        result.append(SUPERSCRIPT_DIGITS[digit]);
    }
    iterator.setIndex(oldIndex);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:15,代码来源:ScientificNumberFormatter.java

示例3: char32AtAndAdvance

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
private static int char32AtAndAdvance(AttributedCharacterIterator iterator) {
    char c1 = iterator.current();
    char c2 = iterator.next();
    if (UCharacter.isHighSurrogate(c1)) {
        // If c2 is DONE, it will fail the low surrogate test and we
        // skip this block.
        if (UCharacter.isLowSurrogate(c2)) {
            iterator.next();
            return UCharacter.toCodePoint(c1, c2);
        }
    }
    return c1;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:14,代码来源:ScientificNumberFormatter.java

示例4: parseReference

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Implement SymbolTable API.  Parse out a symbol reference
 * name.
 */
@Override
public String parseReference(String text, ParsePosition pos, int limit) {
    int start = pos.getIndex();
    int i = start;
    while (i < limit) {
        char c = text.charAt(i);
        if ((i==start && !UCharacter.isUnicodeIdentifierStart(c)) ||
            !UCharacter.isUnicodeIdentifierPart(c)) {
            break;
        }
        ++i;
    }
    if (i == start) { // No valid name chars
        return null;
    }
    pos.setIndex(i);
    return text.substring(start, i);
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:23,代码来源:TransliteratorParser.java

示例5: mirror

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Performs character mirroring without reordering. When this method is
 * called, <code>{@link #text}</code> should be in a Logical form.
 */
private void mirror() {
    if ((reorderingOptions & Bidi.DO_MIRRORING) == 0) {
        return;
    }
    StringBuffer sb = new StringBuffer(text);
    byte[] levels = bidi.getLevels();
    for (int i = 0, n = levels.length; i < n;) {
        int ch = UTF16.charAt(sb, i);
        if ((levels[i] & 1) != 0) {
            UTF16.setCharAt(sb, i, UCharacter.getMirror(ch));
        }
        i += UTF16.getCharCount(ch);
    }
    text = sb.toString();
    reorderingOptions &= ~Bidi.DO_MIRRORING;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:21,代码来源:BidiTransform.java

示例6: separated

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Return the string with interspersed CGJs. Input must have more than 2 codepoints.
 * <p>This is used to test whether contractions sort differently from their components.
 */
private String separated(String item) {
    StringBuilder result = new StringBuilder();
    // add a CGJ except within surrogates
    char last = item.charAt(0);
    result.append(last);
    for (int i = 1; i < item.length(); ++i) {
        char ch = item.charAt(i);
        if (!UCharacter.isHighSurrogate(last) || !UCharacter.isLowSurrogate(ch)) {
            result.append(CGJ);
        }
        result.append(ch);
        last = ch;
    }
    return result.toString();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:20,代码来源:AlphabeticIndex.java

示例7: getFirstCharactersInScripts

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Return a list of the first character in each script. Only exposed for testing.
 *
 * @return list of first characters in each script
 * @internal
 * @deprecated This API is ICU internal, only for testing.
 */
@Deprecated
public List<String> getFirstCharactersInScripts() {
    List<String> dest = new ArrayList<String>(200);
    // Fetch the script-first-primary contractions which are defined in the root collator.
    // They all start with U+FDD1.
    UnicodeSet set = new UnicodeSet();
    collatorPrimaryOnly.internalAddContractions(0xFDD1, set);
    if (set.isEmpty()) {
        throw new UnsupportedOperationException(
                "AlphabeticIndex requires script-first-primary contractions");
    }
    for (String boundary : set) {
        int gcMask = 1 << UCharacter.getType(boundary.codePointAt(1));
        if ((gcMask & (GC_L_MASK | GC_CN_MASK)) == 0) {
            // Ignore boundaries for the special reordering groups.
            // Take only those for "real scripts" (where the sample character is a Letter,
            // and the one for unassigned implicit weights (Cn).
            continue;
        }
        dest.add(boundary);
    }
    return dest;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:31,代码来源:AlphabeticIndex.java

示例8: stripRules

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
static String stripRules(String rules) {
    StringBuilder strippedRules = new StringBuilder();
    int rulesLength = rules.length();
    for (int idx = 0; idx < rulesLength;) {
        char ch = rules.charAt(idx++);
        if (ch == '#') {
            while (idx < rulesLength
                    && ch != '\r' && ch != '\n' && ch != chNEL) {
                ch = rules.charAt(idx++);
            }
        }
        if (!UCharacter.isISOControl(ch)) {
            strippedRules.append(ch);
        }
    }
    return strippedRules.toString();
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:RBBIRuleScanner.java

示例9: requiresBidi

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Return true if the specified text requires bidi analysis. If this returns
 * false, the text will display left-to-right. Clients can then avoid
 * constructing a Bidi object. Text in the Arabic Presentation Forms area of
 * Unicode is presumed to already be shaped and ordered for display, and so
 * will not cause this method to return true.
 *
 * @param text the text containing the characters to test
 * @param start the start of the range of characters to test
 * @param limit the limit of the range of characters to test
 *
 * @return true if the range of characters requires bidi analysis
 *
 * @stable ICU 3.8
 */
public static boolean requiresBidi(char[] text,
        int start,
        int limit)
{
    final int RTLMask = (1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT |
            1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC |
            1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_EMBEDDING |
            1 << UCharacter.DIRECTIONALITY_RIGHT_TO_LEFT_OVERRIDE |
            1 << UCharacter.DIRECTIONALITY_ARABIC_NUMBER);

    for (int i = start; i < limit; ++i) {
        if (((1 << UCharacter.getDirection(text[i])) & RTLMask) != 0) {
            return true;
        }
    }
    return false;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:33,代码来源:Bidi.java

示例10: adjustForContext

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Adjust capitalization of formatted result for display context
 */
private String adjustForContext(String result) {
    if (result != null && result.length() > 0 && UCharacter.isLowerCase(result.codePointAt(0))) {
        DisplayContext capitalization = getContext(DisplayContext.Type.CAPITALIZATION);
        if (  capitalization==DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
              (capitalization == DisplayContext.CAPITALIZATION_FOR_UI_LIST_OR_MENU && capitalizationForListOrMenu) ||
              (capitalization == DisplayContext.CAPITALIZATION_FOR_STANDALONE && capitalizationForStandAlone) ) {
            if (capitalizationBrkIter == null) {
                // should only happen when deserializing, etc.
                capitalizationBrkIter = BreakIterator.getSentenceInstance(locale);
            }
            return UCharacter.toTitleCase(locale, result, capitalizationBrkIter,
                            UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT);
        }
    }
    return result;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:20,代码来源:RuleBasedNumberFormat.java

示例11: getNumerics

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Computes the set of numerics for a string, according to UTS 39 section 5.3.
 */
private void getNumerics(String input, UnicodeSet result) {
    result.clear();

    for (int utf16Offset = 0; utf16Offset < input.length();) {
        int codePoint = Character.codePointAt(input, utf16Offset);
        utf16Offset += Character.charCount(codePoint);

        // Store a representative character for each kind of decimal digit
        if (UCharacter.getType(codePoint) == UCharacterCategory.DECIMAL_DIGIT_NUMBER) {
            // Store the zero character as a representative for comparison.
            // Unicode guarantees it is codePoint - value
            result.add(codePoint - UCharacter.getNumericValue(codePoint));
        }
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:19,代码来源:SpoofChecker.java

示例12: parseSingleLocalizedDigit

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Reads a single decimal digit, either localized digits used by this object
 * or any Unicode numeric character.
 * @param text the text
 * @param start the start index
 * @param len the actual length read from the text
 * the start index is not a decimal number.
 * @return the integer value of the parsed digit, or -1 on failure.
 */
private int parseSingleLocalizedDigit(String text, int start, int[] len) {
    int digit = -1;
    len[0] = 0;
    if (start < text.length()) {
        int cp = Character.codePointAt(text, start);

        // First, try digits configured for this instance
        for (int i = 0; i < _gmtOffsetDigits.length; i++) {
            if (cp == _gmtOffsetDigits[i].codePointAt(0)) {
                digit = i;
                break;
            }
        }
        // If failed, check if this is a Unicode digit
        if (digit < 0) {
            digit = UCharacter.digit(cp);
        }

        if (digit >= 0) {
            len[0] = Character.charCount(cp);
        }
    }
    return digit;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:34,代码来源:TimeZoneFormat.java

示例13: matchesDigit

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Check if the substring at the specified position matches a decimal digit.
 * If matched, this method sets the decimal value to <code>decVal</code> and
 * returns matched length.
 *
 * @param str       The input string
 * @param start     The start index
 * @param decVal    Receives decimal value
 * @return          Length of match, or 0 if the sequence at the position is not
 *                  a decimal digit.
 */
private int matchesDigit(String str, int start, int[] decVal) {
    String[] localeDigits = symbols.getDigitStringsLocal();

    // Check if the sequence at the current position matches locale digits.
    for (int i = 0; i < 10; i++) {
        int digitStrLen = localeDigits[i].length();
        if (str.regionMatches(start, localeDigits[i], 0, digitStrLen)) {
            decVal[0] = i;
            return digitStrLen;
        }
    }

    // If no locale digit match, then check if this is a Unicode digit
    int cp = str.codePointAt(start);
    decVal[0] = UCharacter.digit(cp, 10);
    if (decVal[0] >= 0) {
        return Character.charCount(cp);
    }

    return 0;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:33,代码来源:DecimalFormat.java

示例14: adjustForUsageAndContext

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
private String adjustForUsageAndContext(CapitalizationContextUsage usage, String name) {
    if (name != null && name.length() > 0 && UCharacter.isLowerCase(name.codePointAt(0)) &&
            (capitalization==DisplayContext.CAPITALIZATION_FOR_BEGINNING_OF_SENTENCE ||
            (capitalizationUsage != null && capitalizationUsage[usage.ordinal()]) )) {
        // Note, won't have capitalizationUsage != null && capitalizationUsage[usage.ordinal()]
        // unless capitalization is CAPITALIZATION_FOR_UI_LIST_OR_MENU or CAPITALIZATION_FOR_STANDALONE
        synchronized (this) {
            if (capitalizationBrkIter == null) {
                // should only happen when deserializing, etc.
                capitalizationBrkIter = BreakIterator.getSentenceInstance(locale);
            }
            return UCharacter.toTitleCase(locale, name, capitalizationBrkIter,
                    UCharacter.TITLECASE_NO_LOWERCASE | UCharacter.TITLECASE_NO_BREAK_ADJUSTMENT);
        }
    }
    return name;
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:18,代码来源:LocaleDisplayNamesImpl.java

示例15: getValue

import com.ibm.icu.lang.UCharacter; //导入依赖的package包/类
/**
 * Get a 32 bit data from the table data
 * @param ch  code point for which data is to be retrieved.
 * @param inBlockZero  Output parameter, inBlockZero[0] returns true if the
 *                      char maps into block zero, otherwise false.
 * @return the 32 bit data value.
 */
public int getValue(int ch, boolean [] inBlockZero) 
{
    // valid, uncompacted trie and valid c?
    if (m_isCompacted_ || ch > UCharacter.MAX_VALUE || ch < 0) {
        if (inBlockZero != null) {
            inBlockZero[0] = true;
        }
        return 0;
    }

    int block = m_index_[ch >> SHIFT_];
    if (inBlockZero != null) {
        inBlockZero[0] = (block == 0);
    }
    return m_data_[Math.abs(block) + (ch & MASK_)];
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:24,代码来源:IntTrieBuilder.java


注:本文中的com.ibm.icu.lang.UCharacter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。