当前位置: 首页>>代码示例>>C++>>正文


C++ UnicodeString::indexOf方法代码示例

本文整理汇总了C++中UnicodeString::indexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ UnicodeString::indexOf方法的具体用法?C++ UnicodeString::indexOf怎么用?C++ UnicodeString::indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnicodeString的用法示例。


在下文中一共展示了UnicodeString::indexOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Test

void IdnaConfTest::Test(void){
    if (!ReadAndConvertFile())return;

    UnicodeString s;
    UnicodeString key;
    UnicodeString value;

    // skip everything before the first "=====" and "=====" itself
    do {
        if (!ReadOneLine(s)) {
            errln("End of file prematurely found");
            break;
        }
    }
    while (s.compare(C_TAG, -1) != 0);   //"====="

    while(ReadOneLine(s)){
        s.trim();
        key.remove();
        value.remove();
        if (s.compare(C_TAG, -1) == 0){   //"====="
            Call();
       } else {
            // explain      key:value
            int p = s.indexOf((UChar)0x3A);    // :
            key.setTo(s,0,p).trim();
            value.setTo(s,p+1).trim();
            if (key.compare(C_TYPE, -1) == 0){
                if (value.compare(C_TOASCII, -1) == 0) {
                    type = 0;
                } else if (value.compare(C_TOUNICODE, -1) == 0){
                    type = 1;
                }
            } else if (key.compare(C_PASSFAIL, -1) == 0){
                if (value.compare(C_PASS, -1) == 0){
                    passfail = 0;
                } else if (value.compare(C_FAIL, -1) == 0){
                    passfail = 1;
                }
            } else if (key.compare(C_DESC, -1) == 0){
                if (value.indexOf(C_USESTD3ASCIIRULES, u_strlen(C_USESTD3ASCIIRULES), 0) == -1){
                    option = 1; // not found
                } else {
                    option = 0;
                }
                id.setTo(value, 0, value.indexOf((UChar)0x20));    // space
            } else if (key.compare(C_NAMEZONE, -1) == 0){
                ExplainCodePointTag(value);
                namezone.setTo(value);
            } else if (key.compare(C_NAMEBASE, -1) == 0){
                ExplainCodePointTag(value);
                namebase.setTo(value);
            }
            // just skip other lines
        }
    }

    Call(); // for last record
}
开发者ID:winlibs,项目名称:icu4c,代码行数:59,代码来源:idnaconf.cpp

示例2: IDtoSTV

/**
 * Parse an ID into pieces.  Take IDs of the form T, T/V, S-T,
 * S-T/V, or S/V-T.  If the source is missing, return a source of
 * ANY.
 * @param id the id string, in any of several forms
 * @return an array of 4 strings: source, target, variant, and
 * isSourcePresent.  If the source is not present, ANY will be
 * given as the source, and isSourcePresent will be NULL.  Otherwise
 * isSourcePresent will be non-NULL.  The target may be empty if the
 * id is not well-formed.  The variant may be empty.
 */
void TransliteratorIDParser::IDtoSTV(const UnicodeString & id,
                                     UnicodeString & source,
                                     UnicodeString & target,
                                     UnicodeString & variant,
                                     UBool & isSourcePresent)
{
	source = ANY;
	target.truncate(0);
	variant.truncate(0);

	int32_t sep = id.indexOf(TARGET_SEP);
	int32_t var = id.indexOf(VARIANT_SEP);
	if (var < 0)
	{
		var = id.length();
	}
	isSourcePresent = FALSE;

	if (sep < 0)
	{
		// Form: T/V or T (or /V)
		id.extractBetween(0, var, target);
		id.extractBetween(var, id.length(), variant);
	}
	else if (sep < var)
	{
		// Form: S-T/V or S-T (or -T/V or -T)
		if (sep > 0)
		{
			id.extractBetween(0, sep, source);
			isSourcePresent = TRUE;
		}
		id.extractBetween(++sep, var, target);
		id.extractBetween(var, id.length(), variant);
	}
	else
	{
		// Form: (S/V-T or /V-T)
		if (var > 0)
		{
			id.extractBetween(0, var, source);
			isSourcePresent = TRUE;
		}
		id.extractBetween(var, sep++, variant);
		id.extractBetween(sep, id.length(), target);
	}

	if (variant.length() > 0)
	{
		variant.remove(0, 1);
	}
}
开发者ID:Botyto,项目名称:Core,代码行数:63,代码来源:tridpars.cpp

示例3:

UBool
LocaleUtility::isFallbackOf(const UnicodeString& root, const UnicodeString& child)
{
    return child.indexOf(root) == 0 &&
      (child.length() == root.length() ||
       child.charAt(root.length()) == UNDERSCORE_CHAR);
}
开发者ID:AaronNGray,项目名称:texlive-libs,代码行数:7,代码来源:locutil.cpp

示例4: dataerrln

void
TimeZoneBoundaryTest::findDaylightBoundaryUsingDate(UDate d, const char* startMode, UDate expectedBoundary)
{
    UnicodeString str;
    if (dateToString(d, str).indexOf(startMode) == - 1) {
        logln(UnicodeString("Error: ") + startMode + " not present in " + str);
    }
    UDate min = d;
    UDate max = min + SIX_MONTHS;
    while ((max - min) > INTERVAL) {
        UDate mid = (min + max) / 2;
        UnicodeString* s = &dateToString(mid, str);
        if (s->indexOf(startMode) != - 1) {
            min = mid;
        }
        else {
            max = mid;
        }
    }
    logln("Date Before: " + showDate(min));
    logln("Date After:  " + showDate(max));
    UDate mindelta = expectedBoundary - min;
    UDate maxdelta = max - expectedBoundary;
    if (mindelta >= 0 &&
        mindelta <= INTERVAL &&
        maxdelta >= 0 &&
        maxdelta <= INTERVAL) logln(UnicodeString("PASS: Expected boundary at ") + expectedBoundary);
    else dataerrln(UnicodeString("FAIL: Expected boundary at ") + expectedBoundary);
}
开发者ID:icu-project,项目名称:icu4c,代码行数:29,代码来源:tzbdtest.cpp

示例5: return

UBool  U_EXPORT2 
DateIntervalFormat::fieldExistsInSkeleton(UCalendarDateFields field,
                                          const UnicodeString& skeleton)
{
    const UChar fieldChar = fgCalendarFieldToPatternLetter[field];
    return ( (skeleton.indexOf(fieldChar) == -1)?FALSE:TRUE ) ;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:7,代码来源:dtitvfmt.cpp

示例6: compare

void NormalizerConformanceTest::compare(const UnicodeString& s1, const UnicodeString& s2){
    UErrorCode status=U_ZERO_ERROR;
     // TODO: Re-enable this tests after UTC fixes UAX 21
    if(s1.indexOf((UChar32)0x0345)>=0)return;
    if(Normalizer::compare(s1,s2,U_FOLD_CASE_DEFAULT,status)!=0){
        errln("Normalizer::compare() failed for s1: " + prettify(s1) + " s2: " +prettify(s2));
    }
}
开发者ID:winlibs,项目名称:icu4c,代码行数:8,代码来源:normconf.cpp

示例7: Encode

UnicodeString RegExpManager::Encode(const UnicodeString& regexp) const
{
	UnicodeString result = regexp;
	int32_t pos = 0;

	// Replace + with \+
	while ((pos = result.indexOf('+', pos)) != -1)
	{
		result.insert(pos, '\\');
		pos += 2;
	}
	// Replace ' ' with +
	while ((pos = result.indexOf(' ')) != -1)
	{
		result.setCharAt(pos, '+');
	}
	return result;
}
开发者ID:bjornjohansson,项目名称:ircbot,代码行数:18,代码来源:regexpmanager.cpp

示例8: list

Transliterator* U_EXPORT2
Transliterator::createInstance(const UnicodeString& ID,
                                UTransDirection dir,
                                UParseError& parseError,
                                UErrorCode& status)
{
    if (U_FAILURE(status)) {
        return 0;
    }

    UnicodeString canonID;
    UVector list(status);
    if (U_FAILURE(status)) {
        return NULL;
    }

    UnicodeSet* globalFilter;
    // TODO add code for parseError...currently unused, but
    // later may be used by parsing code...
    if (!TransliteratorIDParser::parseCompoundID(ID, dir, canonID, list, globalFilter)) {
        status = U_INVALID_ID;
        return NULL;
    }
    
    TransliteratorIDParser::instantiateList(list, status);
    if (U_FAILURE(status)) {
        return NULL;
    }
    
    U_ASSERT(list.size() > 0);
    Transliterator* t = NULL;
    
    if (list.size() > 1 || canonID.indexOf(ID_DELIM) >= 0) {
        // [NOTE: If it's a compoundID, we instantiate a CompoundTransliterator even if it only
        // has one child transliterator.  This is so that toRules() will return the right thing
        // (without any inactive ID), but our main ID still comes out correct.  That is, if we
        // instantiate "(Lower);Latin-Greek;", we want the rules to come out as "::Latin-Greek;"
        // even though the ID is "(Lower);Latin-Greek;".
        t = new CompoundTransliterator(list, parseError, status);
    }
    else {
        t = (Transliterator*)list.elementAt(0);
    }
    // Check null pointer
    if (t != NULL) {
        t->setID(canonID);
        if (globalFilter != NULL) {
            t->adoptFilter(globalFilter);
        }
    }
    else if (U_SUCCESS(status)) {
        status = U_MEMORY_ALLOCATION_ERROR;
    }
    return t;
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:55,代码来源:translit.cpp

示例9: dest

int t4p::FinderClass::ReplaceAllMatches(UnicodeString& text) const {
    int matches = 0;

    // no check for ReplaceExpression.isEmpty() allow for empty replacements
    // this allows the user to 'delete' parts of a strin
    if (IsPrepared) {
        UnicodeString replacement = ReplaceExpression;
        RegexMatcher* matcher = NULL;
        UErrorCode error = U_ZERO_ERROR;
        UnicodeString dest(text.length(), ' ', 0);
        int32_t pos = 0;
        if (EXACT == Mode || (REGULAR_EXPRESSION == Mode && ReplaceExpression.isEmpty())) {
            pos = text.indexOf(Expression, 0);
            while (pos >= 0) {
                text.replaceBetween(pos, pos + Expression.length(), replacement);
                pos = text.indexOf(Expression, pos + replacement.length());
                ++matches;
            }
        } else {
            matcher = Pattern->matcher(text, error);
            if (U_SUCCESS(error) && matcher) {
                while (matcher->find()) {
                    if (U_SUCCESS(error)) {
                        matcher->appendReplacement(dest, replacement, error);
                        if (U_SUCCESS(error)) {
                            ++matches;
                        }
                    }
                }
                matcher->appendTail(dest);
                text = dest;
            }
        }
        if (matcher) {
            delete matcher;
        }
    }
    return matches;
}
开发者ID:adjustive,项目名称:triumph4php,代码行数:39,代码来源:FinderClass.cpp

示例10: addNewString

/**
 * Joins originalString and nextString using the pattern pat and puts the result in
 * originalString.
 */
void ListFormatter::addNewString(const UnicodeString& pat, UnicodeString& originalString,
                                 const UnicodeString& nextString, UErrorCode& errorCode) const {
    if (U_FAILURE(errorCode)) {
        return;
    }

    int32_t p0Offset = pat.indexOf(FIRST_PARAMETER, 3, 0);
    if (p0Offset < 0) {
        errorCode = U_ILLEGAL_ARGUMENT_ERROR;
        return;
    }
    int32_t p1Offset = pat.indexOf(SECOND_PARAMETER, 3, 0);
    if (p1Offset < 0) {
        errorCode = U_ILLEGAL_ARGUMENT_ERROR;
        return;
    }

    int32_t i, j;

    const UnicodeString* firstString;
    const UnicodeString* secondString;
    if (p0Offset < p1Offset) {
        i = p0Offset;
        j = p1Offset;
        firstString = &originalString;
        secondString = &nextString;
    } else {
        i = p1Offset;
        j = p0Offset;
        firstString = &nextString;
        secondString = &originalString;
    }

    UnicodeString result = UnicodeString(pat, 0, i) + *firstString;
    result += UnicodeString(pat, i+3, j-i-3);
    result += *secondString;
    result += UnicodeString(pat, j+3);
    originalString = result;
}
开发者ID:AOSC-Dev,项目名称:Pale-Moon,代码行数:43,代码来源:listformatter.cpp

示例11: textLower

bool t4p::FinderClass::FindNextExact(const UnicodeString& text, int32_t start, bool caseSensitive) {
    int32_t foundIndex = 0;
    if (!caseSensitive) {
        UnicodeString textLower(text);
        textLower.toLower();
        UnicodeString expressionLower(Expression);
        expressionLower.toLower();
        foundIndex = textLower.indexOf(expressionLower, start);
    } else {
        foundIndex = text.indexOf(Expression, start);
    }
    IsFound = -1 != foundIndex;
    if (IsFound) {
        LastPosition = foundIndex;
        LastLength = Expression.length();
    }
    return IsFound;
}
开发者ID:adjustive,项目名称:triumph4php,代码行数:18,代码来源:FinderClass.cpp

示例12: UnicodeString

UnicodeString& U_EXPORT2
TimeZoneNamesImpl::getDefaultExemplarLocationName(const UnicodeString& tzID, UnicodeString& name) {
    if (tzID.isEmpty() || tzID.startsWith(gEtcPrefix, gEtcPrefixLen)
        || tzID.startsWith(gSystemVPrefix, gSystemVPrefixLen) || tzID.indexOf(gRiyadh8, gRiyadh8Len, 0) > 0) {
        name.setToBogus();
        return name;
    }

    int32_t sep = tzID.lastIndexOf((UChar)0x2F /* '/' */);
    if (sep > 0 && sep + 1 < tzID.length()) {
        name.setTo(tzID, sep + 1);
        name.findAndReplace(UnicodeString((UChar)0x5f /* _ */),
                            UnicodeString((UChar)0x20 /* space */));
    } else {
        name.setToBogus();
    }
    return name;
}
开发者ID:00zhengfu00,项目名称:third_party,代码行数:18,代码来源:tznames_impl.cpp

示例13: parsedVariable

std::vector<t4p::PhpTagClass> t4p::TagCacheClass::GetTagsAtPosition(
    const wxString& fileName,
    const UnicodeString& code, int posToCheck,
    const std::vector<wxFileName>& sourceDirs, t4p::PhpModuleClass& phpModule,
    wxString& status) {
    std::vector<t4p::PhpTagClass> matches;
    pelet::LexicalAnalyzerClass lexer;
    pelet::ParserClass parser;
    t4p::ScopeFinderClass scopeFinder;
    pelet::ScopeClass variableScope;
    pelet::VariableClass parsedVariable(variableScope);

    lexer.SetVersion(phpModule.Environment.Php.Version);
    parser.SetVersion(phpModule.Environment.Php.Version);
    scopeFinder.SetVersion(phpModule.Environment.Php.Version);

    UnicodeString codeUntilPos(code, 0, posToCheck);

    UnicodeString lastExpression = lexer.LastExpression(codeUntilPos);
    UnicodeString resourceName;
    bool doDuckTyping = true;
    if (!lastExpression.isEmpty()) {
        scopeFinder.GetScopeString(codeUntilPos, posToCheck, variableScope);
        if (lastExpression.indexOf(UNICODE_STRING_SIMPLE("\\")) > 0 &&
                variableScope.ClassName.isEmpty() &&
                variableScope.MethodName.isEmpty()) {
            // the expression is a namespace name outside a class or method.  this is
            // most likely a namespace in the "use" statement
            // namespace in a use statement is always fully qualified, even if it does
            // not begin with a backslash
            lastExpression = UNICODE_STRING_SIMPLE("\\") + lastExpression;
        }
        parser.ParseExpression(lastExpression, parsedVariable);
        t4p::SymbolTableMatchErrorClass error;
        ResourceMatches(fileName, parsedVariable, variableScope, sourceDirs, matches,
                        doDuckTyping, true, error);
        if (matches.empty()) {
            HandleAutoCompletionPhpStatus(error, lastExpression, parsedVariable,
                                          variableScope, matches, status);
        }
    }
    return matches;
}
开发者ID:62BRAINS,项目名称:triumph4php,代码行数:43,代码来源:TagCacheClass.cpp

示例14: populatePrefixSuffix

// populatePrefixSuffix Adds a specific prefix-suffix pair to result for a
// given variant and log10 value.
// variant is 'zero', 'one', 'two', 'few', 'many', or 'other'.
// formatStr is the format string from which the prefix and suffix are
// extracted. It is usually of form 'Pefix 000 suffix'.
// populatePrefixSuffix returns the number of 0's found in formatStr
// before the decimal point.
// In the special case that formatStr contains only spaces for prefix
// and suffix, populatePrefixSuffix returns log10Value + 1.
static int32_t populatePrefixSuffix(
    const char* variant, int32_t log10Value, const UnicodeString& formatStr, UHashtable* result, UBool overwrite, UErrorCode& status) {
  if (U_FAILURE(status)) {
    return 0;
  }
  int32_t firstIdx = formatStr.indexOf(kZero, UPRV_LENGTHOF(kZero), 0);
  // We must have 0's in format string.
  if (firstIdx == -1) {
    status = U_INTERNAL_PROGRAM_ERROR;
    return 0;
  }
  int32_t lastIdx = formatStr.lastIndexOf(kZero, UPRV_LENGTHOF(kZero), firstIdx);
  CDFUnit* unit = createCDFUnit(variant, log10Value, result, status);
  if (U_FAILURE(status)) {
    return 0;
  }

  // Return -1 if we are not overwriting an existing value
  if (unit->isSet() && !overwrite) {
    return -1;
  }
  unit->markAsSet();

  // Everything up to first 0 is the prefix
  unit->prefix = formatStr.tempSubString(0, firstIdx);
  fixQuotes(unit->prefix);
  // Everything beyond the last 0 is the suffix
  unit->suffix = formatStr.tempSubString(lastIdx + 1);
  fixQuotes(unit->suffix);

  // If there is effectively no prefix or suffix, ignore the actual number of
  // 0's and act as if the number of 0's matches the size of the number.
  if (onlySpaces(unit->prefix) && onlySpaces(unit->suffix)) {
    return log10Value + 1;
  }

  // Calculate number of zeros before decimal point
  int32_t idx = firstIdx + 1;
  while (idx <= lastIdx && formatStr.charAt(idx) == u_0) {
    ++idx;
  }
  return (idx - firstIdx);
}
开发者ID:MoonchildProductions,项目名称:Pale-Moon,代码行数:52,代码来源:compactdecimalformat.cpp

示例15: Decode

UnicodeString RegExpManager::Decode(const UnicodeString& regexp) const
{
	UnicodeString result = regexp;
	int32_t pos = 0;

	while ((pos = result.indexOf('+', pos)) != -1)
	{
		// If the + is not preceeded by a \ we replace it with a ' '
		// Otherwise we remove the \ and leave the +
		if (pos == 0 || result[pos - 1] != '\\')
		{
			result.setCharAt(pos, L' ');
		}
		else
		{
			result.remove(pos - 1, 1);
		}
		++pos;
	}
	return result;
}
开发者ID:bjornjohansson,项目名称:ircbot,代码行数:21,代码来源:regexpmanager.cpp


注:本文中的UnicodeString::indexOf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。