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

U_STABLE UStringSearch* U_EXPORT2 usearch_open ( const UChar pattern,
int32_t  patternlength,
const UChar text,
int32_t  textlength,
const char *  locale,
UBreakIterator *  breakiter,
UErrorCode status 

Creating a search iterator data struct using the argument locale language rule set. A collator will be created in the process, which will be owned by this search and will be deleted in usearch_close.

patternfor matching
patternlengthlength of the pattern, -1 for null-termination
texttext string
textlengthlength of the text string, -1 for null-termination
localename of locale for the rules to be used
breakiterA BreakIterator that will be used to restrict the points at which matches are detected. If a match is found, but the match's start or end index is not a boundary as determined by the BreakIterator, the match will be rejected and another will be searched for. If this parameter is NULL, no break detection is attempted.
statusfor errors if it occurs. If pattern or text is NULL, or if patternlength or textlength is 0 then an U_ILLEGAL_ARGUMENT_ERROR is returned.
search iterator data structure, or NULL if there is an error. ICU 2.4

Definition at line 2602 of file usearch.cpp.


    if (U_FAILURE(*status)) {
        return NULL;
    if (breakiter != NULL) {
        *status = U_UNSUPPORTED_ERROR;
        return NULL;
    if (locale) {
        // ucol_open internally checks for status
        UCollator     *collator = ucol_open(locale, status);
        // pattern, text checks are done in usearch_openFromCollator
        UStringSearch *result   = usearch_openFromCollator(pattern,
                                              patternlength, text, textlength,
                                              collator, breakiter, status);

        if (result == NULL || U_FAILURE(*status)) {
            if (collator) {
            return NULL;
        else {
            result->ownCollator = TRUE;
        return result;
    return NULL;

Generated by  Doxygen 1.6.0   Back to index