Search in sources :

Example 1 with FCDUTF16CollationIterator

use of android.icu.impl.coll.FCDUTF16CollationIterator in project j2objc by google.

the class CollationTest method TestFCD.

@Test
public void TestFCD() {
    CollationData data = CollationRoot.getData();
    // Input string, not FCD.
    StringBuilder buf = new StringBuilder();
    buf.append("\u0308\u00e1\u0062\u0301\u0327\u0430\u0062").appendCodePoint(// MUSICAL SYMBOL QUARTER NOTE=1D158 1D165, ccc=0, 216
    0x1D15F).append(// ccc=202, 230
    "\u0327\u0308").appendCodePoint(// MUSICAL SYMBOL COMBINING AUGMENTATION DOT, ccc=226
    0x1D16D).appendCodePoint(0x1D15F).appendCodePoint(0x1D16D).append("\uac01").append(// Character with tccc!=0 decomposed together with mis-ordered sequence.
    "\u00e7").appendCodePoint(0x1D16D).appendCodePoint(0x1D165).append(// Character with tccc!=0 decomposed together with decomposed sequence.
    "\u00e1").append(// Tibetan composite vowels must be decomposed.
    "\u0f73\u0f75").append("\u4e00\u0f81");
    String s = buf.toString();
    // Expected code points.
    int[] cp = { 0x308, 0xe1, 0x62, 0x327, 0x301, 0x430, 0x62, 0x1D158, 0x327, 0x1D165, 0x1D16D, 0x308, 0x1D15F, 0x1D16D, 0xac01, 0x63, 0x327, 0x1D165, 0x1D16D, 0x61, 0xf71, 0xf71, 0xf72, 0xf74, 0x301, 0x4e00, 0xf71, 0xf80 };
    FCDUTF16CollationIterator u16ci = new FCDUTF16CollationIterator(data, false, s, 0);
    CodePointIterator cpi = new CodePointIterator(cp);
    checkFCD("FCDUTF16CollationIterator", u16ci, cpi);
    cpi.resetToStart();
    UCharacterIterator iter = UCharacterIterator.getInstance(s);
    FCDIterCollationIterator uici = new FCDIterCollationIterator(data, false, iter, 0);
    checkFCD("FCDIterCollationIterator", uici, cpi);
}
Also used : FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UCharacterIterator(android.icu.text.UCharacterIterator) CollationData(android.icu.impl.coll.CollationData) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) Test(org.junit.Test)

Example 2 with FCDUTF16CollationIterator

use of android.icu.impl.coll.FCDUTF16CollationIterator in project j2objc by google.

the class CollationElementIterator method setText.

/**
 * Set a new source string for iteration, and reset the offset
 * to the beginning of the text.
 *
 * @param source the new source string for iteration.
 */
public void setText(String source) {
    // TODO: do we need to remember the source string in a field?
    string_ = source;
    CollationIterator newIter;
    boolean numeric = rbc_.settings.readOnly().isNumeric();
    if (rbc_.settings.readOnly().dontCheckFCD()) {
        newIter = new UTF16CollationIterator(rbc_.data, numeric, string_, 0);
    } else {
        newIter = new FCDUTF16CollationIterator(rbc_.data, numeric, string_, 0);
    }
    iter_ = newIter;
    otherHalf_ = 0;
    dir_ = 0;
}
Also used : FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator) CollationIterator(android.icu.impl.coll.CollationIterator) FCDIterCollationIterator(android.icu.impl.coll.FCDIterCollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) IterCollationIterator(android.icu.impl.coll.IterCollationIterator)

Example 3 with FCDUTF16CollationIterator

use of android.icu.impl.coll.FCDUTF16CollationIterator in project j2objc by google.

the class RuleBasedCollator method setVariableTop.

/**
 * <strong>[icu]</strong> Sets the variable top to the primary weight of the specified string.
 *
 * <p>Beginning with ICU 53, the variable top is pinned to
 * the top of one of the supported reordering groups,
 * and it must not be beyond the last of those groups.
 * See {@link #setMaxVariable(int)}.
 *
 * @param varTop
 *            one or more (if contraction) characters to which the variable top should be set
 * @return variable top primary weight
 * @exception IllegalArgumentException
 *                is thrown if varTop argument is not a valid variable top element. A variable top element is
 *                invalid when
 *                <ul>
 *                <li>it is a contraction that does not exist in the Collation order
 *                <li>the variable top is beyond
 *                    the last reordering group supported by setMaxVariable()
 *                <li>when the varTop argument is null or zero in length.
 *                </ul>
 * @see #getVariableTop
 * @see RuleBasedCollator#setAlternateHandlingShifted
 * @deprecated ICU 53 Call {@link #setMaxVariable(int)} instead.
 * @hide original deprecated declaration
 */
@Override
@Deprecated
public int setVariableTop(String varTop) {
    checkNotFrozen();
    if (varTop == null || varTop.length() == 0) {
        throw new IllegalArgumentException("Variable top argument string can not be null or zero in length.");
    }
    boolean numeric = settings.readOnly().isNumeric();
    long ce1, ce2;
    if (settings.readOnly().dontCheckFCD()) {
        UTF16CollationIterator ci = new UTF16CollationIterator(data, numeric, varTop, 0);
        ce1 = ci.nextCE();
        ce2 = ci.nextCE();
    } else {
        FCDUTF16CollationIterator ci = new FCDUTF16CollationIterator(data, numeric, varTop, 0);
        ce1 = ci.nextCE();
        ce2 = ci.nextCE();
    }
    if (ce1 == Collation.NO_CE || ce2 != Collation.NO_CE) {
        throw new IllegalArgumentException("Variable top argument string must map to exactly one collation element");
    }
    internalSetVariableTop(ce1 >>> 32);
    return (int) settings.readOnly().variableTop;
}
Also used : FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) FCDUTF16CollationIterator(android.icu.impl.coll.FCDUTF16CollationIterator) UTF16CollationIterator(android.icu.impl.coll.UTF16CollationIterator)

Aggregations

FCDUTF16CollationIterator (android.icu.impl.coll.FCDUTF16CollationIterator)3 FCDIterCollationIterator (android.icu.impl.coll.FCDIterCollationIterator)2 UTF16CollationIterator (android.icu.impl.coll.UTF16CollationIterator)2 CollationData (android.icu.impl.coll.CollationData)1 CollationIterator (android.icu.impl.coll.CollationIterator)1 IterCollationIterator (android.icu.impl.coll.IterCollationIterator)1 UCharacterIterator (android.icu.text.UCharacterIterator)1 Test (org.junit.Test)1