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

UnicodeString & UnicodeSet::_toPattern ( UnicodeString result,
UBool  escapeUnprintable 
) const [private]

Append a string representation of this set to result. This will be a cleaned version of the string passed to applyPattern(), if there is one. Otherwise it will be generated.

Definition at line 1942 of file uniset.cpp.

References _generatePattern(), UnicodeString::append(), UnicodeString::length(), NULL, pat, UnicodeString::truncate(), and U16_NEXT.

Referenced by applyPattern(), and toPattern().

{
    if (pat != NULL) {
        int32_t i;
        int32_t backslashCount = 0;
        for (i=0; i<patLen; ) {
            UChar32 c;
            U16_NEXT(pat, i, patLen, c);
            if (escapeUnprintable && ICU_Utility::isUnprintable(c)) {
                // If the unprintable character is preceded by an odd
                // number of backslashes, then it has been escaped.
                // Before unescaping it, we delete the final
                // backslash.
                if ((backslashCount % 2) == 1) {
                    result.truncate(result.length() - 1);
                }
                ICU_Utility::escapeUnprintable(result, c);
                backslashCount = 0;
            } else {
                result.append(c);
                if (c == BACKSLASH) {
                    ++backslashCount;
                } else {
                    backslashCount = 0;
                }
            }
        }
        return result;
    }

    return _generatePattern(result, escapeUnprintable);
}


Generated by  Doxygen 1.6.0   Back to index