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

UnicodeString & Transliterator::toRules ( UnicodeString result,
UBool  escapeUnprintable 
) const [virtual, inherited]

Create a rule string that can be passed to createFromRules() to recreate this transliterator.

Parameters:
result the string to receive the rules. Previous contents will be deleted.
escapeUnprintable if TRUE then convert unprintable character to their hex escape representations, \uxxxx or \Uxxxxxxxx. Unprintable characters are those other than U+000A, U+0020..U+007E. ICU 2.0

Reimplemented in CompoundTransliterator, and RuleBasedTransliterator.

Definition at line 1135 of file translit.cpp.

References UnicodeString::append(), Transliterator::getID(), UnicodeString::insert(), UnicodeString::truncate(), UNICODE_STRING_SIMPLE, and UTF_CHAR_LENGTH.

Referenced by TransliteratorTest::TestBeginEndToRules(), TransliteratorTest::TestCompoundRBT(), TransliteratorTest::TestInstantiation(), TransliteratorTest::TestQuantifiedSegment(), TransliteratorTest::TestRegisterAlias(), and CompoundTransliterator::toRules().

                                                                      {
    // The base class implementation of toRules munges the ID into
    // the correct format.  That is: foo => ::foo
    if (escapeUnprintable) {
        rulesSource.truncate(0);
        UnicodeString id = getID();
        for (int32_t i=0; i<id.length();) {
            UChar32 c = id.char32At(i);
            if (!ICU_Utility::escapeUnprintable(rulesSource, c)) {
                rulesSource.append(c);
            }
            i += UTF_CHAR_LENGTH(c);
        }
    } else {
        rulesSource = getID();
    }
    // KEEP in sync with rbt_pars
    rulesSource.insert(0, UNICODE_STRING_SIMPLE("::"));
    rulesSource.append(ID_DELIM);
    return rulesSource;
}


Generated by  Doxygen 1.6.0   Back to index