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

int32_t SpoofImpl::scriptScan ( const UChar *  text,
int32_t  length,
int32_t &  pos,
UErrorCode status 
) const

Scan a string to determine how many scripts it includes. Ignore characters with script=Common and scirpt=Inherited.

Parameters:
text The UChar text to be scanned
length The length of the input text, -1 for nul termintated.
pos An out parameter, set to the first input postion at which a second script was encountered, ignoring Common and Inherited.
status For errors.
Returns:
the number of (non-common,inherited) scripts encountered, clipped to a max of two.

Definition at line 375 of file uspoof_impl.cpp.

References U16_NEXT, and U_FAILURE.

Referenced by uspoof_areConfusable(), and uspoof_check().

                                                                                    {
    if (U_FAILURE(status)) {
        return 0;
    }
    int32_t       inputIdx = 0;
    UChar32       c;
    int32_t       scriptCount = 0;
    UScriptCode   lastScript = USCRIPT_INVALID_CODE;
    UScriptCode   sc = USCRIPT_INVALID_CODE;
    while ((inputIdx < length || length == -1) && scriptCount < 2) {
        U16_NEXT(text, inputIdx, length, c);
        if (c == 0 && length == -1) {
            break;
        }
        sc = uscript_getScript(c, &status);
        if (sc == USCRIPT_COMMON || sc == USCRIPT_INHERITED || sc == USCRIPT_UNKNOWN) {
            continue;
        }
        if (sc != lastScript) {
           scriptCount++;
           lastScript = sc;
        }
    }
    if (scriptCount == 2) {
        pos = inputIdx;
    }
    return scriptCount;
}


Generated by  Doxygen 1.6.0   Back to index