Logo Search packages:      
Sourcecode: icu version File versions  Download package

int32_t UnicodeSet::getSingleCP ( const UnicodeString s  )  [static, private]

Returns:
a code point IF the string consists of a single one. otherwise returns -1.
Parameters:
s string to test
Returns:
a code point IF the string consists of a single one. otherwise returns -1.
Parameters:
string to test

Definition at line 1039 of file uniset.cpp.

References UnicodeString::char32At(), UnicodeString::charAt(), and UnicodeString::length().

Referenced by add(), complement(), contains(), and remove().

                                                      {
    //if (s.length() < 1) {
    //    throw new IllegalArgumentException("Can't use zero-length strings in UnicodeSet");
    //}
    if (s.length() > 2) return -1;
    if (s.length() == 1) return s.charAt(0);

    // at this point, len = 2
    UChar32 cp = s.char32At(0);
    if (cp > 0xFFFF) { // is surrogate pair
        return cp;
    }
    return -1;
}


Generated by  Doxygen 1.6.0   Back to index