Logo Search packages:      
Sourcecode: icu version File versions

void EscapeTransliterator::handleTransliterate ( Replaceable text,
UTransPosition pos,
UBool  isIncremental 
) const [protected, virtual]

Implements Transliterator#handleTransliterate.

Implements Transliterator.

Definition at line 130 of file esctrn.cpp.

References UnicodeString::append(), Replaceable::char32At(), Replaceable::charAt(), UTransPosition::contextLimit, FALSE, grokSupplementals, Replaceable::handleReplaceBetween(), UnicodeString::length(), UTransPosition::limit, minDigits, NULL, prefix, radix, UTransPosition::start, suffix, supplementalHandler, TRUE, UnicodeString::truncate(), and UTF_CHAR_LENGTH.

{
    /* TODO: Verify that isIncremental can be ignored */
    int32_t start = pos.start;
    int32_t limit = pos.limit;

    UnicodeString buf(prefix);
    int32_t prefixLen = prefix.length();
    UBool redoPrefix = FALSE;

    while (start < limit) {
        int32_t c = grokSupplementals ? text.char32At(start) : text.charAt(start);
        int32_t charLen = grokSupplementals ? UTF_CHAR_LENGTH(c) : 1;

        if ((c & 0xFFFF0000) != 0 && supplementalHandler != NULL) {
            buf.truncate(0);
            buf.append(supplementalHandler->prefix);
            ICU_Utility::appendNumber(buf, c, supplementalHandler->radix,
                                  supplementalHandler->minDigits);
            buf.append(supplementalHandler->suffix);
            redoPrefix = TRUE;
        } else {
            if (redoPrefix) {
                buf.truncate(0);
                buf.append(prefix);
                redoPrefix = FALSE;
            } else {
                buf.truncate(prefixLen);
            }
            ICU_Utility::appendNumber(buf, c, radix, minDigits);
            buf.append(suffix);
        }

        text.handleReplaceBetween(start, start + charLen, buf);
        start += buf.length();
        limit += buf.length() - charLen;
    }

    pos.contextLimit += limit - pos.limit;
    pos.limit = limit;
    pos.start = start;
}


Generated by  Doxygen 1.6.0   Back to index